# Aggregating Data in T-SQL

Aggregates turn many rows into answers: totals, averages, counts. You will use T-SQL functions, aggregate with COUNT, SUM and AVG, group results with GROUP BY, and filter groups with HAVING.

Updated: November 3, 2026

## [Common T-SQL Functions](https://www.ask-codey.com/courses/csharp-full-stack-bootcamp/topics/common-t-sql-functions)

1. [Common T-SQL Functions](https://www.ask-codey.com/lessons/common-t-sql-functions) (Apprentice): T-SQL's built-in functions work on one row at a time. Join and change text, put a value in place of NULL, and pull apart dates and round numbers.

## [Aggregate Functions in T-SQL](https://www.ask-codey.com/courses/csharp-full-stack-bootcamp/topics/aggregate-functions-in-t-sql)

1. [Calculations vs Aggregations](https://www.ask-codey.com/lessons/aggregate-functions-in-t-sql-calculations-vs-aggregations) (Apprentice): A calculation works within one row and returns a value for every row; an aggregation works across many rows and returns one value for all of them.
2. [Common Aggregate Functions](https://www.ask-codey.com/lessons/aggregate-functions-in-t-sql-common-aggregate-functions) (Apprentice): COUNT counts rows or values, SUM adds them, AVG averages them, and MIN and MAX find the smallest and largest. All but COUNT(\*) skip NULL.
3. [Grouping Aggregations](https://www.ask-codey.com/lessons/aggregate-functions-in-t-sql-grouping-aggregations) (Journeyman): GROUP BY splits the rows into groups and runs the aggregates once per group. Every column in the SELECT that isn't aggregated must be in the GROUP BY.
4. [HAVING](https://www.ask-codey.com/lessons/aggregate-functions-in-t-sql-having) (Journeyman): WHERE filters rows before they're grouped; HAVING filters the groups afterward, by their aggregates. Know which to use, and the order a query's clauses run in.

## [Exercise: Aggregating Data](https://www.ask-codey.com/courses/csharp-full-stack-bootcamp/topics/exercise-aggregating-data)

1. [Exercise: Aggregating Data](https://www.ask-codey.com/lessons/exercise-aggregating-data) (Journeyman): Twelve questions about Northwind, answered with COUNT, SUM, AVG, MIN, MAX, GROUP BY and HAVING, each with the result to expect.

Source: https://www.ask-codey.com/courses/csharp-full-stack-bootcamp/chapters/aggregating-data-in-t-sql
