T Sql 简明教程

T-SQL - Numeric Functions

MS SQL Server numeric functions can be applied on numeric data and will return numeric data.

Following is the list of Numeric functions with examples.

ABS()

Absolute value will come as output for numeric expression.

Example

The following query will give the absolute value.

Select ABS(-22)

ACOS()

Arc cosine value will come as output for the specified numeric expression.

Example

The following query will give the arc cosine value of 0.

Select ACOS(0)

ASIN()

Arc sine value will come as output for the specified numeric expression.

Example

The following query will give the arc sine value of 0.

Select ASIN(0)

ATAN()

Arc tangent value will come as output for the specified numeric expression.

Example

以下查询将给出一个弧切 0 的数值。

Select ATAN(0)

ATN2()

特定数值表达式的值将作为输出值以所有象限上的弧切值给出的。

Example

以下查询将给出一个 0 的所有四个象限内的弧切值。

Select ATN2(0, -1)

可以将 CUSTOMERS 表视为包含以下记录。

ID  NAME       AGE       ADDRESS             SALARY
1   Ramesh     32        Ahmedabad           2000.00
2   Khilan     25        Delhi               1500.00
3   kaushik    23        Kota                2000.00
4   Chaitali   25        Mumbai              6500.00
5   Hardik     27        Bhopal              8500.00
6   Komal      22        MP                  4500.00
7   Muffy      24        Indore              10000.00

BETWEEN()

如果给出的两个表达式之间存在值域,它将成为一个输出。

Example

以下查询将给出以下输出。

SELECT salary from customers where salary between 2000 and 8500

Output

salary
2000.00
2000.00
6500.00
8500.00
4500.00

MIN()

给定表达式的最小值将作为输出。

Example

以下查询将给出一个针对客户表中给定的“工资”表达式的“1500.00”。

Select MIN(salary)from CUSTOMERS

MAX()

给定的表达式的最大值将作为输出。

Example

以下查询将给出针对客户表中给定的“工资”表达式的“10000.00”。

Select MAX(salary)from CUSTOMERS

SQRT()

给定数值表达式的平方根将作为输出。

Example

以下查询将给出一个针对 4 的数值表达式的 2。

Select SQRT(4)

PI()

PI 值将作为输出。

Example

以下查询将给出一个 3.14159265358979 针对 PI 值。

Select PI()

CEILING()

四舍五入小数后的给定值将作为输出,这将是下一个最高值。

Example

以下查询将给出一个针对 123.25 值的 124。

Select CEILING(123.25)

FLOOR()

四舍五入后给定值将作为输出,它将小于或等于表达式。

Example

以下查询将给出一个针对 123.25 值的 123。

Select FLOOR(123.25)

LOG()

给定表达式的自然对数将作为输出。

Example

以下查询将给出一个针对给定值 1 的 0。

Select LOG(1)