Aggregation and ordering operators
ORDER BY
The ORDER BY keyword is used to sort the result-set in ascending or descending order.
The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.
MIN
The MIN()
function returns the smallest value of the selected column.
MAX
The MAX()
function returns the largest value of the selected column.
COUNT
The COUNT()
function returns the number of rows that matches a specified criterion.
AVG
The AVG() function returns the average value of a numeric column.
SUM
The SUM() function returns the total sum of a numeric column.
GROUP BY
The GROUP BY
statement groups rows that have the same values into summary rows, like "find the number of customers in each country".
The GROUP BY
statement is often used with aggregate functions (COUNT()
, MAX()
, MIN()
, SUM()
, AVG()
) to group the result-set by one or more columns.
HAVING
The HAVING
clause was added to SQL because the WHERE
keyword cannot be used with aggregate functions.
References
Last updated
Was this helpful?