Function | Details |
---|---|
AVG |
Average of a set of values |
COUNT |
Number of items in a set |
MAX |
Maximum value in a set |
MIN |
Minimum value in a set |
SUM |
Sum of all or distinct values in a set |
6 SQL Functions
6.1 Aggregate Functions
6.2 Math Functions
Function | Details |
---|---|
ABS |
Absolute value |
ACOS |
Arc cosine of an argument |
ASIN |
Arc sine of an argument |
ATAN |
Arc tangent of an argument |
CEILING, CEIL |
Returns the closest whole number (integer) upward from a decimal point |
COS |
Cosine of an argument |
COT |
Cotangent of an argument |
DEGREES |
Convert radian values to degree |
DIV |
Allows dividing integers |
EXP |
The constant e (2.71828…) that raises to a power of a specified number |
FLOOR |
Returns whole number (integer) downward from a decimal point |
LN |
Natural logarithm of the argument |
LOG |
Natural logarithm of the first argument |
LOG10 |
Base 10 logarithm of the argument |
LOG2 |
Base 2 logarithm of the argument |
MOD |
Remainder (modulo) of a number divided by another |
PI |
The value of pi which is 3.14159265358979 |
POWER |
A number raised to a power of a specified number |
RAND |
A random floating point value |
ROUND |
Rounds a number to a specific precision |
SIGN |
Sign of an argument |
SIN |
Sine of an argument |
SQRT |
Square root of an argument |
TAN |
Tangent of an argument |
TRUNCATE |
Truncates to a specified number of decimal places |
6.3 String Functions
Function | Details |
---|---|
ASCII |
ASCII code of the first character of a string |
CHAR_LENGTH |
Character length of a string |
CHR |
Character corresponding to the input ASCII code |
CONCAT |
Result of the concatenation of two or more strings |
LEFT |
Extract a string from the left with the given number |
LENGTH, LEN |
The length of a string in bytes |
LOCATE |
Locates the first occurrence of one string within a string |
LOWER, LCASE |
Converts all characters in a string to lowercase |
LTRIM |
Remove any leading spaces from the given string. |
MID |
Extracts one string from another, starting from any position. |
POSITION |
Returns the position of the first time one substring appears within another. |
REPEAT |
Repeat a string |
REPLACE |
Replaces all occurrences of a specified substring in a string by a new substring |
REVERSE |
Reverse a string |
RIGHT |
Extract a string from the right with the given number |
RTRIM |
Removes any trailing spaces from the given string. |
SPACE |
Returns a string full of spaces equal to the amount you pass it. |
STRCOMP |
Compares two strings for differences |
SUBSTRING |
Extracts a substring from a string |
SUBSTRING, SUBSTR |
Extracts one substring from another, starting from any position. |
TRIM |
Removes unwanted characters e.g., whitespaces from a string |
UPPER, UCASE |
Converts all characters in a string to uppercase |
6.4 Date Functions
Function | Details |
---|---|
CURRENT_DATE |
Current date |
CURRENT_TIME |
Current time |
CURRENT_TIMESTAMP |
Current date and time |
DATEADD |
Add an interval to a date |
DATEDIFF |
Find the difference between two dates |
DATEPART |
Extract a part of a date such as a year, month, and day from a given date |