Unanswered: How to specify precision of number in SQL
I have the value +3.84000020000000E+001 and would like it to be displayed as 3.84 so basically I would like to round it off to the 2nd decimal place and specify precision for the number of digits to display.. I found the ROUND function but can't find anything to specify the precision.. any thoughts? Thanks!
db2user, That is what the PS was for. I am not at a place where I could test to be sure so I tried to indicate you might need to convert it buy using either the CAST or DECIMAL function (as Lenny showed).
By the way, Lenny77, will that Round or Truncate to 2 decimal places. What if the value was +3.84050020000000E+001? Would you get 38.4 or 38.5?
It turns out that this works just fine when I run it from the command line.. but I really want this value returned as a part of a stored procedure. I have an OUT parameter READINGVAL which is of DOUBLE type and decimal(ROUND(+3.84000020000000E+001,2), 31, 2) is assigned to it and returned.
When I run the procedure, I still get it in the long scientific format --
Parameter Name : READINGVAL
Parameter Value : +3.84000000000000E+001
Any way around this? Should I return it as a string instead?
I tried it with the output parameter as DECIMAL type where I'm doing something like --
SET READINGVAL = DECIMAL(ROUND(+3.84000020000000E+001,2), 31, 2); and it returns "38." instead of "38.40"