SQL Aggregate Functions Explained: COUNT, SUM, AVG, MIN, MAX and GROUP BY
SQL aggregate functions allow developers to summarize large datasets by returning a single computed value from multiple rows. The core functions include COUNT for tallying rows, SUM for totaling numeric columns, AVG for calculating averages, and MIN/MAX for finding extreme values. A key behavior to note is that AVG automatically ignores NULL values, while COUNT(*) includes all rows regardless of nulls. The GROUP BY clause extends these functions by computing results per group rather than across the entire table, enabling breakdowns by category, customer, or any other column. One important rule is that every non-aggregated column in a SELECT statement must also appear in the GROUP BY clause.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in