Oracle数学函数和SQL数学函数的区别
Oracle数学函数和SQL Server中的数学函数不太一样。
①绝对值
S:select abs(-1) value
O:select abs(-1) value from dual
②取整(大)
S:select ceiling(-001) value
O:select ceil(-001) value from dual
③取整(小)
S:select floor(-001) value
O:select floor(-001) value from dual
④取整(截取)
S:select cast(-002 as int) value
O:select trunc(-002) value from dual
⑤四舍五入
S:select round(23456,4) value 23460
O:select round(23456,4) value from dual 2346
⑥e为底的幂
S:select Exp(1) value
O:select Exp(1) value from dual
⑦取e为底的对数
S:select log(7182818284590451) value
O:select ln(7182818284590451) value from dual;
⑧取10为底对数
S:select log10(10) value
O:select log(10,10) value from dual;
⑨取平方
S:select SQUARE(4) value
O:select power(4,2) value from dual
⑩取平方根
S:select SQRT(4) value
O:select SQRT(4) value from dual
求任意数为底的幂
S:select power(3,4) value
O:select power(3,4) value from dual
取随机数
S:select rand() value
O:select sys.dbms_random.value(0,1) value from dual;
取符号
S:select sign(-8) value -1
O:select sign(-8) value from dual -1
符号使用0,1标识:
select power(-1,1) from dual; 表示-1,负数
select power(-1,0) from dual; 表示1, 正数