What are aggregate functions?
SQLLevel: FoundationAggregations Basics
What are aggregate functions?
Hints
- Define one output row and the source-table keys.
- Check duplicates, NULLs and the order of filtering and aggregation.
Answer
Aggregate functions operate on a set of rows and return a single value. The main ones:
COUNT()— number of rows / non-NULL valuesSUM()— totalAVG()— average (ignores NULLs)MIN()— minimum valueMAX()— maximum valueSTRING_AGG()/GROUP_CONCAT()— concatenate strings (PostgreSQL / MySQL)ARRAY_AGG()— aggregate into array (PostgreSQL)
Source and licence: SQL Interview Questions — Arda Kocadoru · MIT