Aggregate Functions

Aggregate functions calculate a single value across many rows — a count, a total, an average.

COUNT, SUM, AVG

counting rows
Result
average salary
Result

Grouping with GROUP BY

GROUP BY splits rows into groups before aggregating — so instead of one overall average, you get one average per department:

average salary per department
Result
Note: any column you SELECT alongside an aggregate function needs to either be in the GROUP BY clause or be inside another aggregate function.