Reputation: 145
I am trying to calculate the average ice creams a kid will have during summer. I want the result to have 2 decimals. Query:
Select day, (sum(ice_cream_cones) *1.0)/(select count(kids))
From t1 Group by 1
The result I get is something like 1.0003. I only want 2 decimal points. Any suggestions?
Upvotes: 0
Views: 2768
Reputation: 4061
You can do this with round
Select day, round((sum(ice_cream_cones) *1.0)/(select count(kids) ), 2)
From t1
Upvotes: 1
Reputation: 86706
Assuming your source data are integers...
SUM(ice_cream_cones) * 100 / COUNT(kids) / 100.0
Or, cast your existing calculation to a decimal?
CAST(<calc> AS DECIMAL(8,2))
Upvotes: 1