sign函数语法:
sign(n)
sign函数说明:
取数字n的符号,大于0返回1,小于0返回-1,等于0返回0
示例:
select sign( 100 ),sign(- 100 ),sign( 0 ) from dual;
SIGN(100) SIGN(-100) SIGN(0)
———- ———- ———-
1 -1 0
trunc(number)
在Oracle/PLSQL中, trunc function returns a number truncated to a certain number of decimal places.
trunc函数返回一个数字被截断到一定数目的小数位
trunc function 语法如下:
trunc( number, [ decimal_places ] )
number 要截取的数字.
decimal_places 要保留的小数位. 这个参数必须是个整数. 如果此参数缺省,默认保留0位小数
应用于:
Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g
例如For example:
trunc(125.815) would return 125
trunc(125.815, 0) would return 125
trunc(125.815, 1) would return 125.8
trunc(125.815, 2) would return 125.81
trunc(125.81, 3) would return 125.81
trunc(-125.815, 2) would return -125.81
trunc(125.815, -1) would return 120
trunc(125.815, -2) would return 100
trunc(125.81, -3) would return 0
如果decimal_places 大于number 本身的小数位数,返回原数字不会加0.
如:trunc(125.81,3) would return 125.81;
如果decimal_places 为负数,那么将指定的位数