-
使用数学函数查询
1.ABS
返回给定数字表达式的绝对值 ABS( numeric_expression )
select abs(-1.0),abs(0.0),abs(1.0)
go
2. DEGREES
当给出以弧度为单位的角度时,返回相应的以度数为单位的角度 DEGREES ( numeric_expression )
select 'PI/2 is '+ convert(varchar,degrees((pi()/2)))
go
3. RAND
返回0到1之间的随机float值 RAND ( [ seed ] )
declare @counter smallint
set @counter=1
while @counter<4
begin
select rand(@counter) 随机数
set nocount on
set @counter = @counter +1
set nocount off
end
go
4.ACOS
返回以弧度表示的角度值,该角度值的余弦为给定的 float 表达式;本函数亦称反余弦 ACOS ( float_expression )
SET NOCOUNT OFF
DECLARE @angle float
SET @angle = -1
SELECT 'The ACOS of the angle is: ' + CONVERT(varchar, ACOS(@angle))
go
5.EXP
返回所给的 float 表达式的指数值 EXP ( float_expression )
DECLARE @var float
SET @var = 378.615345498
SELECT 'The EXP of the variable is: ' + CONVERT(varchar,EXP(@var))
GO
6.ROUND
返回数字表达式并四舍五入为指定的长度或精度。ROUND ( numeric_expression , length [ , function ] )
select round(123.45178,2) ,round(123.98765,2),round(123.98765,-2),round(123.56789,0),round(123.56789,0,1)
go
7.ASIN
返回以弧度表示的角度值,该角度值的正弦为给定的 float 表达式;亦称反正弦 ASIN ( float_expression )
declare @angle float
set @angle =0.123
select convert(varchar,asin(@angle))
go
8.FLOOR
返回小于或等于所给数字表达式的最大整数。FLOOR ( numeric_expression )
select floor(123.456),floor(-123.456),floor($123.456)
go
9.SING
返回给定表达式的正 (+1)、零 (0) 或负 (-1) 号 SIGN ( numeric_expression )
DECLARE @value real
SET @value = -1
WHILE @value < 2
BEGIN
SELECT SIGN(@value)
SET NOCOUNT ON
SELECT @value = @value + 1
SET NOCOUNT OFF
END
SET NOCOUNT OFF
GO
10.ATAN
返回以弧度表示的角度值,该角度值的正切为给定的 float 表达式;亦称反正切 ATAN ( float_expression )
SELECT 'The ATAN of 0.1472738 is: ' + CONVERT(varchar, ATAN(0.1472738))
go
11.LOG
返回给定 float 表达式的自然对数 LOG ( float_expression )
DECLARE @var float
SET @var = 5.175643
SELECT 'The LOG of the variable is: ' + CONVERT(varchar,LOG(@var))
GO
12.SIN
以近似数字 (float) 表达式返回给定角度(以弧度为单位)的三角正弦值。SIN ( float_expression )
DECLARE @angle float
SET @angle = 45.175643
SELECT 'The SIN of the angle is: ' + CONVERT(varchar,SIN(@angle))
GO
13.ATN2
返回以弧度表示的角度值,该角度值的正切介于两个给定的 float 表达式之间;亦称反正切 ATN2 ( float_expression , float_expression )
DECLARE @angle1 float
DECLARE @angle2 float
SET @angle1 = 35.175643
SET @angle2 = 129.44
SELECT 'The ATN2 of the angle is: ' + CONVERT(varchar,ATN2(@angle1,@angle2 ))
GO
14.LOG10
返回给定 float 表达式的以 10 为底的对数 LOG10 ( float_expression )
DECLARE @var float
SET @var = 145.175643
SELECT 'The LOG10 of the variable is: ' + CONVERT(varchar,LOG10(@var))
GO
15.SQUARE
返回给定表达式的平方 SQUARE ( float_expression )
DECLARE @h float, @r float
SET @h = 5
SET @r = 1
SELECT PI()* SQUARE(@r)* @h AS 'Cyl Vol'
go
16.CEILING
返回大于或等于所给数字表达式的最小整数 CEILING ( numeric_expression )
SELECT CEILING($123.45), CEILING($-123.45), CEILING($0.0)
GO
17.PI
返回 PI 的常量值 PI ( )
select pi()
go
18.SQRT
返回给定表达式的平方根 SQRT ( float_expression )
DECLARE @myvalue float
SET @myvalue = 1.00
WHILE @myvalue < 10.00
BEGIN
SELECT SQRT(@myvalue)
SELECT @myvalue = @myvalue + 1
END
GO
19.COS
一个数学函数,返回给定表达式中给定角度(以弧度为单位)的三角余弦值 COS ( float_expression )
DECLARE @angle float
SET @angle = 14.78
SELECT 'The COS of the angle is: ' + CONVERT(varchar,COS(@angle))
GO
20.POWER
返回给定表达式乘指定次方的值 POWER ( numeric_expression , y )
DECLARE @value int, @counter int
SET @value = 2
SET @counter = 1
WHILE @counter < 5
BEGIN
SELECT POWER(@value, @counter)
SET NOCOUNT ON
SET @counter = @counter + 1
SET NOCOUNT OFF
END
GO
21.TAN
返回输入表达式的正切值 TAN ( float_expression )
SELECT TAN(PI()/2)
go
22.COT
一个数学函数,返回给定 float 表达式中指定角度(以弧度为单位)的三角余切值 COT ( float_expression )
DECLARE @angle float
SET @angle = 124.1332
SELECT 'The COT of the angle is: ' + CONVERT(varchar,COT(@angle))
GO
23.RADIANS
对于在数字表达式中输入的度数值返回弧度值 RADIANS ( numeric_expression )
DECLARE @angle float
SET @angle = -45.01
SELECT 'The RADIANS of the angle is: ' +
CONVERT(varchar, RADIANS(@angle))
GO
-
相关阅读:
Ubuntu上64位adv无法创建问题
Java 数据结构与算法分析学习
博客第一天——新的梦幻之旅
android开发第一天
Ubuntu下OpenGL开发环境的搭建
[ZZ]WindowsForm应用程序调用WebService
WindowsForm应用程序调用WebService
Hello World
Apache Ant编写build.xml的自动提示 ANT DTD
Serial Interface之I2C:关于DS1624 2线通信SDA保持时间的说明
-
原文地址:https://www.cnblogs.com/tenghoo/p/545676.html
Copyright © 2020-2023
润新知