Aggregate Functions
Aggregate functions calculate a single value across many rows — a count, a total, an average.
COUNT, SUM, AVG
Grouping with GROUP BY
GROUP BY splits rows into groups before aggregating — so instead of one overall average, you get one average per department:
Note: any column you
SELECT alongside an aggregate function needs to either be in the GROUP BY clause or be inside another aggregate function.