I have following list of Amount (float) in my table.
Amount
123
123.1
123.0123
123.789456
How can i get the number of digits a
And one more way:
SELECT Amount,
CASE WHEN deci = 0 THEN 0 ELSE LEN(deci) END AS Result
FROM (
SELECT Amount,
TRY_CAST(REVERSE(REPLACE(Amount - TRY_CAST(Amount as int),'0.','')) as int) as deci
FROM (VALUES
(123),
(123.1),
(123.0123),
(123.789456)
) as t (Amount)
) as t
Output:
Amount Result
123.000000 0
123.100000 1
123.012300 4
123.789456 6