October 16, 2013 at 7:53 am
Hello,
I have a report that I am reverse engineering. The percentage for a specific column is 52.80%, but in my result set I continue to get 53. It's obviously rounding the number. Does anyone have a quick script that can convert this whole number to 52.80?
Any help would be appreciated.
Dave
October 16, 2013 at 7:56 am
October 16, 2013 at 7:58 am
Apologies. Here it is....
round(cast(sum(columnname) as float)*100,3)PrcntSvcLvl
October 16, 2013 at 8:10 am
October 16, 2013 at 8:14 am
0.53
October 16, 2013 at 8:17 am
October 16, 2013 at 8:17 am
What is the data type of 'columnname'?
casting the sum as a float is no good if it was not one before. The precision has been lost before the conversion
October 16, 2013 at 8:18 am
0.53
October 16, 2013 at 8:19 am
numeric(5,2)
October 16, 2013 at 8:21 am
October 16, 2013 at 8:22 am
I can easily change the datatype column. What should that be? Decimal?
October 16, 2013 at 8:22 am
Thanks very much for your time Sean.
October 16, 2013 at 8:24 am
Where did you get the conclusion that the answer should be 52.8? Can you give us sample data?
October 16, 2013 at 3:14 pm
What does:
round(cast(sum(columnname) as numeric(5,3))*100.00,3)
give you?
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply