本文介绍了四舍五入数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想舍入两列的值:
select a.region as "Regions",
a.suminsured,2 as "SumInsured" ,
a.suminsured/b.sum*100 as pct
from (
SELECT region, sum(suminsured) as suminsured
FROM "Exposure_commune" group by region
) a,
(select sum(suminsured) FROM "Exposure_commune") b
我希望 suminsured
和 pct
列带有2个小数位。有人可以告诉我该怎么做吗?
I want the suminsured
and pct
columns to come with 2 decimal places. Can someone tell me what I should do?
推荐答案
您可以直接使用带有两个参数的数字。舍入十进制的第二个参数。
You can use directly numeric with two parameters. Second parameter for round decimal.
select sum(column_name::numeric(10,2)) from tablename
这篇关于四舍五入数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!