SQL Server SERVER 2005 数学函数整理
2022-11-12 09:52:17
内容摘要
这篇文章主要为大家详细介绍了SQL Server SERVER 2005 数学函数整理,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记!MSSQL SERVER 2005 数
文章正文
这篇文章主要为大家详细介绍了SQL Server SERVER 2005 数学函数整理,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记!
MSSQL SERVER 2005 数学函数1.求绝对值ABS()select FWeight-50,ABS(FWeight-50),ABS(-5.38) from T_Person2.求幂POWER(X,Y) 用来计算X的Y次幂select FWeight,POWER(FWeight,-0.5),POWER(FWeight,2),POWER(FWeight,3),POWER(FWeight,4) from T_Personselect Power(2,2)3.求平方根SQRT()select FWeight,SQRT(FWeight) from T_Person4. 求随机数RAND() 支持有参数,也可以没参数select RAND()select RAND(123)5.舍入到最大整数CEILING()select FName,FWeight,CEILING(FWeight),CEILING(FWeight*-1) from T_Person6.舍入到最小整数FLOOR()select FName,FWeight,FLOOR(FWeight),FLOOR(FWeight*-1) from T_Person7.四舍五入ROUND()ROUND(m,d) m为待进行四舍五入的数值,d为计算精度,也就是四舍五入时保留的小数位数d为0表示不保留小数位,d为负值表示在整数部分进行四舍五入。select FName,FWeight,ROUND(FWeight,1),ROUND(FWeight*-1,0),ROUND(FWeight,-1) from T_Person8.求正弦值SIN()select FName,FWeight,SIN(FWeight)from T_Person9.求余弦值COS()select FName,FWeight,COS(FWeight) from T_Person10.求反正弦ASIN()select FName,FWeight,ASIN(1/FWeight) from T_Person11.求反余弦ACOS()select FName,FWeight,ACOS(1/FWeight) from T_Person12.求正切值TAN()select FName,FWeight,TAN(FWeight) from T_Person13.求反正切值ATAN()select FName,FWeight,ATAN(FWeight) from T_Person14.求两个变量的反正切ATN2(X,Y) 类似于计算Y/X的反正切select FName,FWeight,ATN2(Fweight,2) from T_Person15.求余切COT()select FName,FWeight,COT(Fweight) from T_Person16.求圆周率π值PI()select FName,FWeight,Fweight*PI(),PI() from T_Person17.弧度制转换为角度制DEGREES() 结果的精确度与参数有关select DEGREES(PI()),DEGREES(3.0),DEGREES(3)18.角度制转换为弧度制RADIANS() 结果的精确度与参数有关select RADIANS(180),RADIANS(180.0)19.求符号SIGN() 返回一个数值的符号,如果数值大于0则返回1,如果数值等于0则返回0,如果数值小于0则返回-1.结果的精确度与参数有关select FName,FWeight-48.68,SIGN(FWeight-48.68),SIGN(1),SIGN(1.000) from T_Person20.求整除余数 %select FName,FWeight,FWeight%5 from T_Person21.求自然对数LOG()select FName,FWeight,LOG(FWeight),LOG(1.00) from T_Person22.求以10为底的对数LOG10()select FName,Fweight,LOG10(FWeight),LOG10(100) from T_Personps:主要参照《程序员的SQL金典》实例有所改动。T_Person表的创建代码如下:
create table T_Person
(
FIdNumber varchar(20),
FName varchar(20),
FBirthDay datetime,
FRegDay datetime,
FWeight numeric(10,2),
)
注:关于SQL Server SERVER 2005 数学函数整理的内容就先介绍到这里,更多相关文章的可以留意
代码注释