This lab covers SQL built-in aggregate functions, data grouping, and grouping with ROLLUP.
SQL provides some built-in functions for performing data aggregation and grouping. The main ones are:
COUNT() – the number of rowsMAX() – the largest valueMIN() – the smallest valueSUM() – the sumAVG() – the average valueVARIANCE() – The statistical variance : the variability from the averageSTDDEV() – The statistical standard deviationAggregate functions can be used as expressions only in the following:
Basic syntax:
SELECT *aggregate_function*([DISTINCT] *expression*), ... FROM *tbl_name,...* [WHERE *where_condition*];
where expression is a column or an expression involving columns (like an arithmetic expression). expression cannot be however an aggregate function.
SELECT MIN(price) AS "Lowest price" FROM Product;