Aggregate functions return a single result row based on input consisting of groups of rows.
Aggregate functions can be used in the select lists of a SELECT clause, typically in conjunction with a GROUP BY clause, and in a HAVING clause.
Aggregate functions can be applied to columns or to expressions, but cannot be used in an expression that contains another aggregate expression. For example, the expression SUM(AVG(pi * r * r)) is invalid.
All aggregate functions except COUNT() ignore NULL values when performing their aggregate calculations, but return a value of NULL when all input passed to the function consists of NULLs.
When you use DISTINCT with aggregate functions, input with duplicate values is considered only once when performing calculations. For example, the values 1, 1, 1, 2, 3 submitted to the function SELECT MEDIAN(DISTINCT col1) are considered by the function as 1, 2, 3.