/*trunc(x[,y])
【功能】返回x按精度y截取后的值
【参数】x,y,数字型表达式,如果y不为整数则截取y整数部分,如果y>0则截取到y位小数,如果y小于0则截取到小数点向左第y位,
小数前其它数据用0表示。
【返回】数字*/
Select Trunc(12.5123) As truncnum,
Trunc(12.5123, 6) As truncnum, --小数部分截取位置多余,不补0
Trunc(12.5123, 2) As truncnum,
Trunc(12.5123, 2.6) As truncnum, --截取位数 2.6 同 2
Trunc(12.5123, 0.1) As truncnum,
Trunc(12.5123, 0) As truncnum,
Trunc(12.5123, -3) As truncnum --整数部分截取位置多余,为0
From dual;
--正负号不同,其余一致
Select Trunc(-12.5, 3) As truncnum, --小数部分截取位置多余,不补0
Trunc(-12.5123, 0) As truncnum,
Trunc(-12.5123, -0.1) As truncnum,--同 0
Trunc(-12.5123, -1) As truncnum,
Trunc(-12.5123, -3) As truncnum --整数部分截取位置多余,为0
From dual;