What is an aggregate function in SQL?
Why Interviewers Ask This
Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Database Design / Normalization basics — a prerequisite for any developer role.
Answer
Aggregate functions perform calculations on a set of rows and return a single value. Common functions: COUNT(*) — number of rows; SUM(column) — total of values; AVG(column) — average; MAX(column) — maximum; MIN(column) — minimum. Used with GROUP BY to compute aggregates per group: SELECT dept_id, COUNT(*) FROM employees GROUP BY dept_id. HAVING filters groups after aggregation (like WHERE for groups): HAVING COUNT(*) > 10. Aggregate functions ignore NULL values (except COUNT(*) which counts all rows).
Pro Tip
Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a Database Design / Normalization codebase.