Database

Aggregation

A SQL operation that computes a single result from a set of values, such as SUM, COUNT, AVG, MIN, or MAX.

In Depth

Aggregation in SQL refers to operations that compute a single summary value from a set of input values. The standard aggregate functions are COUNT (number of rows), SUM (total of values), AVG (average), MIN (smallest value), and MAX (largest value). Aggregations are typically combined with GROUP BY to compute summaries per group (e.g., total revenue per department) and HAVING to filter groups based on aggregate values. Advanced aggregations include PERCENTILE_CONT, STRING_AGG, ARRAY_AGG, and user-defined aggregate functions. Window functions (OVER clause) provide aggregations across a "window" of rows related to the current row without collapsing the result set—enabling running totals, moving averages, and rankings.

How AI for Database Helps

AI for Database automatically applies the right aggregations when you ask summary questions like "What is the total revenue by region?"

Related Terms

Ready to try AI for Database?

Query your database in plain English. No SQL required. Start free today.