sql - 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?
解决方案
你可以用圆形来做到这一点
Select day, round((sum(ice_cream_cones) *1.0)/(select count(kids) ), 2)
From t1
推荐阅读
- typescript - 使用 typescript 接口/类型限制访问 toString
- r - 如何使西里尔文数据集可识别?
- postman - 检查变量内容
- html - 为什么这个基本菜单列表偏离中心并且与下面的文本不对齐?
- mysql - 违反唯一约束时,INSERT IGNORE 不会发出警告
- php - 如何使用 shell_exec() 在 Windows XAMPP 上运行 linux 命令
- python - 训练期间的每类验证准确度
- excel - 循环在当前目录中创建的新文件夹中将范围保存为 pdf 文件
- reactjs - 如何在graphql的内联片段中获取数据?
- google-calendar-api - 使用 kloudless 从多个 calendarId 获取事件