以下的文章主要是对SQL Server与Oracle常用函数的比较,本文主要包括对数学函数与三角函数相关的常用函数的具体内容的介绍,以下就是具体方案的描述,希望在你今后的学习中会有所帮助。
数学函数
1.绝对值
S:selectabs(-1)value O:selectabs(-1)valuefromdual
2.取整(大)
S:selectceiling(-1.001)value O:selectceil(-1.001)valuefromdual
3.取整(小)
S:select floor(-1.001) value
O:select floor(-1.001) value from dual
4.取整(截取)
S:select cast(-1.002 as int) value
O:select trunc(-1.002) value from dual
5.四舍五入
S:select round(1.23456,4) value 1.23460
O:select round(1.23456,4) value from dual 1.2346
6.e为底的幂
S:select Exp(1) value 2.7182818284590451
O:select Exp(1) value from dual 2.71828182
7.取e为底的对数
S:select log(2.7182818284590451) value 1
O:select ln(2.7182818284590451) value from dual; 1
8.取10为底对数
S:select log10(10) value 1
O:select log(10,10) value from dual; 1
9.取平方
S:select SQUARE(4) value 16
O:select power(4,2) value from dual 16
10.取平方根
S:select SQRT(4) value 2
O:select SQRT(4) value from dual 2
11.求任意数为底的幂
S:select power(3,4) value 81
O:select power(3,4) value from dual 81
12.取随机数
S:select rand() value
O:select sys.dbms_random.value(0,1) value from dual;
13.取符号
S:select sign(-8) value -1
O:select sign(-8) value from dual -1
三角函数相关
14.圆周率
S:SELECT PI() value 3.1415926535897931
O:SELECT ACOS(-1)from dual 3.1415926535897932384626433832795028842
15.sin,cos,tan 参数都以弧度为单位
S:SELECT sin() value
O:SELECT sin() value from dual
16.Asin,Acos,Atan,Atan2 参数都以弧度为单位
S:SELECT Asin() value
O:SELECT Asin() value from dual
17.弧度角度互换
S:DEGREES:弧度-〉角度 RADIANS:角度-〉弧度
O:没有提供内建的弧度和角度的转换函数。
数值间比较
18. 求集合***值
S:selectmax(value)valuefrom (select1value union select-2value union select4value union select3value)a O:selectgreatest(1,-2,4,3)valuefromdual