Function | Description | Standard |
avg(x) | Computes the average of all values x. If no values were averaged, this returns NULL (since an average of no values is indefinite) | ANSI |
count(x) | Returns the number of non-NULL values x. If no values were counted, this function returns 0. It does not count NULL values. To cause this function to count all rows in a SQL query, regardless of NULLs, then pass a constant value to count(), as in count(1). count(1) is the same as count(*) in other SQL languages. | ANSI, except Centrallix requires count(1) instead of count(*). |
first(x) | Returns the first value x encountered. Note that in most cases, the order of values returned from a SQL query can not be guaranteed, so the meaningfulness of first() is highly dependent on the context of its use. This is sometimes useful along with ORDER BY to select the first value of x occurring in rows sorted by a different field. | MS Access |
last(x) | Returns the last value x encountered. See discussion for first(). | MS Access |
nth(x,n) | Returns the nth value x encountered. | MySQL/Oracle use nth_value() |
max(x) | Returns the highest value x encountered. If no values were found (or all were NULL), this function returns NULL. | ANSI |
min(x) | Returns the smallest value x encountered. | ANSI |
sum(x) | Returns the sum of all values x that were encountered. If no values were seen (or all were NULL), sum() returns NULL. This function, when x represents a string value, will return the concatenation of non-NULL values of x. | ANSI, except on Strings. MySQL uses group_concat() for summing strings. |