SQL Numeric Functions
The table is created relative to MS SQL Server arithmetical functions set.
Function Name | Description |
---|---|
ABS() | Returns the absolute (positive) value of a number. SELECT ABS(-10) -- 10 |
ACOS() | Returns the arc cosine of a number. SELECT ACOS(0.5) -- 1.0471975511966 |
ASIN() | Returns the arc sine of a number. SELECT ASIN(0.5) -- 0.523598775598299 |
ATAN() | Returns the arc tangent of a number. SELECT ATAN(0.5) -- 0.463647609000806 |
ATN2() | Returns the arc tangent of two numbers. SELECT ATN2(1,1) -- 0.785398163397448 |
CEILING() | Returns the smallest integer greater than or equal to a given number. SELECT CEILING(3.14) -- 4 |
COS() | Returns the cosine of a number. SELECT COS(0) -- 1 |
COT() | Returns the cotangent of a number. SELECT COT(1) -- 0.642092615934331 |
DEGREES() | Converts radians to degrees. SELECT DEGREES(1) -- 57.2957795130823 |
EXP() | Returns the exponential value of a number. SELECT EXP(1) -- 2.71828182845905 |
FLOOR() | Returns the largest integer less than or equal to a given number. SELECT FLOOR(3.14) -- 3 |
LOG() | Returns the natural logarithm of a number. SELECT LOG(10) -- 2.30258509299405 |
LOG10() | Returns the base-10 logarithm of a number. SELECT LOG10(100) -- 2 |
PI() | Returns the value of pi. SELECT PI() -- Result: 3.14159265358979 |
POWER() | Returns the value of a number raised to a specified power. SELECT POWER(2,3) -- 8 |
RADIANS() | Converts degrees to radians. SELECT RADIANS(180) -- 3.14159265358979 |
RAND() | Returns a random float value between 0 and 1. SELECT RAND() -- 0.987654321098765 |
ROUND() | Returns a number rounded to a specified number of decimal places. SELECT ROUND(3.14159, 2) -- 3.14 |
SIGN() | Returns the sign of a number (-1 for negative numbers, 0 for zero, 1 for positive numbers). SELECT SIGN(-5) -- -1 |
SIN() | Returns the sine of a number. SELECT SIN(0) -- 0 |
SQRT() | Returns the square root of a number. SELECT SQRT(25) -- 5 |
SQUARE() | Returns the square of a number. SELECT SQUARE(5) -- 25 |
TAN() | Returns the tangent of a number. SELECT TAN(0) -- 0 |
Part of the aggregate functions are defined with T-SQL.
Function Name | Description |
---|---|
AVG() | Returns the average value of a set of values. SELECT AVG(SalesAmount) FROM SalesData -- 1500 |
COUNT() | Returns the number of values in a set. SELECT COUNT(*) FROM Customers -- 100 |
MAX() | Returns the maximum value in a set of values. SELECT MAX(SalesAmount) FROM SalesData -- 5000 |
MIN() | Returns the minimum value in a set of values. SELECT MIN(SalesAmount) FROM SalesData -- 1000 |
SUM() | Returns the sum of a set of values. SELECT SUM(SalesAmount) FROM SalesData -- Result: 150000 |
STDEV() | Returns the statistical standard deviation of a set of values. SELECT STDEV(SalesAmount) FROM SalesData -- 1000 |
STDEVP() | Returns the statistical standard deviation of a population of values. SELECT STDEVP(SalesAmount) FROM SalesData -- 943.4 |
VAR() | Returns the statistical variance of a set of values. SELECT VAR(SalesAmount) FROM SalesData -- 1000000 |
VARP() | Returns the statistical variance of a population of values. SELECT VARP(SalesAmount) FROM SalesData -- 890000 |
Комментарии
Отправить комментарий