What is data aggregation?
Definition
Aggregation summarises rows instead of returning each one separately. SQL functions such as COUNT, SUM and AVG calculate common summaries.
A query can produce one overall result or use GROUP BY to calculate a result for each category. The records included and how they are grouped both affect the answer.
Why it matters
An overall total can make a large dataset easier to understand, but it can also hide the differences that matter. An average order value may change because individual orders changed, because the mix of customers changed or because the query includes a different set of records. The summary alone does not establish the explanation.
Choose the calculation and grouping together. Check whether you need a count of rows or distinct customers, whether an average should be weighted and how missing values are treated. Be careful when combining summaries: adding counts from overlapping groups can count the same person more than once. Compare the aggregate with a few underlying records so the summary remains connected to the data it represents.