Skip to main content

What is data aggregation in SQL?

Data aggregation in SQL is combining a set of rows into one summary value using aggregate functions.

These functions count, total, or average data across groups.

Examples of aggregate functions

  • COUNT(), counts the number of rows,
  • SUM(), totals values,
  • AVG(), computes the average,
  • MIN() / MAX(), find the minimum and maximum.

Example

sql
SELECT department, AVG(salary) FROM employees GROUP BY department;

This query groups employees by department and computes the average salary in each department.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.