首页 > 解决方案 > Want decimal result Amazon Redshift

问题描述

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?

标签: sqldecimalamazon-redshift

解决方案


你可以用圆形来做到这一点

Select day, round((sum(ice_cream_cones) *1.0)/(select count(kids) ), 2)
From t1

推荐阅读