1.round函数(四舍五入)
(1)dbscontrol设定round函数使用Teradata方式进行四舍五入
//使用root用户登录数据库节点 dbscontrol display general 20. RoundHalfwayMagUp = FALSE //默认为false,普通的四舍五入方式 modify general 20=true write quit
设定完毕后使用如下命令重启数据库,生效配置。
tpareset -f ‘RoundHalfwayMagUp = true‘
(2)Teradata四舍五入方式详解
//5后边有数且大于0进位 cast(3.751 as decimal(18,1)) ==>3.8进位 //5后边无值或为0,前一位奇进偶不进 cast(3.75 as decimal(18,1)) ==>3.8进位 cast(3.85 as decimal(18,1)) ==>3.8不进位
(3)正常四舍五入方式详解
round(1.58) ==> 2 进位,保留整数 round(1.54,1) ==> 1.5不进位,保留一位小数
2.ceil函数(向上取整)
ceil(1.15)==>2
3.floor函数(向下取整)
floor(1.8)==>1
4.trunc函数(截断)
trunc(1.58) ==>1 trunc(1.58,1)==>1.5
原文:https://www.cnblogs.com/badboy200800/p/10491369.html