Aggregate Functions
Explore the use of aggregate functions in T-SQL to compute averages, counts, minimums, maximums, and sums over multiple rows. Understand how to apply these functions correctly in SELECT statements, and learn the differences between COUNT variations and the proper use of aggregate expressions.
We'll cover the following...
We'll cover the following...
An aggregate function is a function that takes in multiple values and returns a single value. It can be viewed as a function that performs an operation over the values of multiple rows.
In T-SQL, we have these aggregate functions:
AVG(): Returns the average of supplied valuesCOUNT(): Returns the number of rowsMIN(): Returns the minimum valueMAX(): Returns the maximum valueSUM(): Returns the sum
As an argument, all aggregate functions take an expression that returns a range of values. Often, the expression is the name of the column over the values of which we want to perform the operation:
SELECT ...