Simple Aggregate Functions
The simple aggregate functions are the ones that came with SQL from the beginning. Every product will have them. They are usually fast because optimizers and index structures often store this data for their own use.
Simple aggregate functions first construct a column of values as defined by the parameter. The parameter is usually a single column name, but it can be an expression with scalar functions and calculations. Pretty much the only things that cannot be used as parameters are other aggregate functions (e.g., SUM(AVG(x)) is illegal) and a subquery (e.g., AVG(SELECT col1 FROM SomeTable WHERE …) is illegal). A subquery could return more than one value, so it would not fit into a column and an aggregate function ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access