What is an aggregate function in SQL?
Updated 2026-07-10 · Beginner friendly
Quick answer
An aggregate function takes many rows and returns a single summary value. The common ones are COUNT, SUM, AVG, MIN, and MAX. They are often used with GROUP BY to produce a summary per group, such as the total sales for each region.
The common aggregates
- COUNT: how many rows.
- SUM: the total of a numeric column.
- AVG: the average value.
- MIN and MAX: the smallest and largest values.
SELECT region, SUM(amount) AS total
FROM sales
GROUP BY region;
-- one total per region
Without GROUP BY an aggregate summarises the whole table into one row. With GROUP BY it summarises each group separately.
In the interview
Watch the COUNT trap. COUNT(*) counts all rows, while COUNT(column) skips nulls in that column. Mentioning this difference shows you know how nulls quietly change results.
Common follow up questions
Related interview questions
Want the full SQL guide?
Read every SQL concept with notes, diagrams, and code in one place. Track your progress as you go.
Open the SQL guide All SQL questions