I need to be able to display data in a different decimal format depending on the value of a selected column ("myDecimalData "). Below does not work, every value is displayed in hundredths, and I do not understand why. How would I accomplish this?
For instance, my data:
less than 10 --> sample: I want to display 9.00 as 9.00
between 10 and 1000 --> sample: I want to display 10.11as 10.1
greater than 1000 --> sample: I want to display 1000.11 as 1000
For instance, my data:
less than 10 --> sample: I want to display 9.00 as 9.00
between 10 and 1000 --> sample: I want to display 10.11as 10.1
greater than 1000 --> sample: I want to display 1000.11 as 1000
Code:
SELECT CASE WHEN myDecimalData > 1000 THEN CONVERT(int, myDecimalData) WHEN myDecimalData < 10 THEN CONVERT(DECIMAL(18, 2), myDecimalData) WHEN myDecimalData between 10 and 1000 THEN CONVERT(DECIMAL(18, 1), myDecimalData) END as NewDecimalData from myTable
Comment