Analytics Center Functions¶
List of Built-in Functions¶
Function |
Description |
Result Data Types |
Examples |
---|---|---|---|
AVG |
Returns the average of the values in a group. Null values are ignored. |
Numeric, Money |
|
COUNT |
Returns the number of items in a group. |
Numeric. |
|
MAX |
Returns the maximum value in a group. |
The same data type as expression. |
|
MIN |
Returns the minimum value in a group. |
The same data type as expression. |
|
SUM |
Returns the sum of all the values in a group. Null values are ignored. |
The same data type as expression. |
|
LEN |
Returns the number of characters of the given text expression, excluding trailing blanks. |
Numeric. |
|
ROUND |
Returns the expression rounded to the specified length or precision. |
The same data type as expression. |
|
CONCAT |
Returns the concatenation of all the parameters in that exact order. |
Text. |
|
GETDATE |
Returns the current system date and time. |
Datetime. |
|
DATEADD |
Returns a new datetime value based on adding an interval to the specified date. |
Datetime. |
|
DATEDIFF |
Returns the number of date and time boundaries crossed between two specified dates. |
Numeric. |
|
DATEPART |
Returns a number representing the specified datepart of the specified date. |
Numeric. |
|
CONVERT |
Explicitly converts an expression of one data type to another, similar to |
The same data type as data_type. |
|
CAST..AS |
Explicitly converts an expression of one data type to another, similar to |
The same data type as data_type. |
|
ISNULL |
Returns the value of check_expression if it is not NULL; otherwise, returns the value of replacement_expression. |
The same data type as expression. |
|
BETWEEN..AND |
Returns TRUE if the value of test_expression is greater than or equal to the value of begin_expression and less than or equal to the value of end_expression, otherwise returns FALSE. |
Boolean. |
|
AND |
Returns TRUE when both expressions are TRUE, otherwise returns FALSE. |
Boolean. |
|
OR |
Returns TRUE when either expression is TRUE, otherwise returns FALSE. |
Boolean. |
|
DISTINCT |
Returns unique values. |
The same data type as expression. |
|
IFF |
Returns the value of true_expression when boolean_expression is TRUE, otherwise returns the value of false_expression. |
The highest precedence data type from data types of true_expression and false_expression. |
|
IF..THEN..ELSE..END |
Returns the value of true_expression when boolean_expression is TRUE, otherwise returns the value of false_expression. |
The highest precedence data type from data types of true_expression and false_expression. |
|
CASE WHEN..THEN..ELSE..END |
Returns the value of result_expression matching the first when_expression with the value equal to input_expression, otherwise return the value of else_result_expression. |
The highest precedence data type from data types of all |
|
CASE..WHEN..THEN..ELSE..END |
Returns the value of result_expression matching the first when_expression with the value equal to input_expression, otherwise return the value of else_result_expression. |
The highest precedence data type from data types of all |
|
**CASE WHEN…THEN…ELSE…END |
Returns the value of result_expression matching the first when_expression with the value equal to input_expression, otherwise return the value of else_result_expression. |
The highest precedence data type from data types of all |
|
RUNNINGSUM |
Returns the sum of all the values of expression from the first row up to the current row. |
The same data type as expression. |
|
RUNNINGAVG |
Returns the average of all the values of expression from the first row up to the current row. |
The same data type as expression. |
|
RUNNINGCOUNT |
Returns the number of unique values of expression from the first row up to the current row. |
Numeric. |
|
List of Dateparts and Abbreviations¶
Datepart |
Abbreviations |
year |
yy, yyyy |
quarter |
qq, q |
month |
mm, m |
dayofyear |
dy, y |
day |
dd, d |
week |
ww, wk |
weekday |
dw |
hour |
hh |
minute |
mi, n |
second |
ss, s |
millisecond |
ms |