T-SQL Aggregate Functions
Aggregate functions perform a calculation on a set of values, and returns a single value. MIN, MAX, and SUM are frequently used aggregate functions.
An aggregate function performs a calculation on a set of values, and returns a single value.
Except for
COUNT(*)
, aggregate functions ignore null values.MAX returns NULL when there is no row to select. MAX ignores any null values.
Aggregate functions are often used with the GROUP BY clause of the SELECT statement.
All aggregate functions are deterministic. In other words, aggregate functions return the same value every time that they are called with a specific set of input values.
Use aggregate functions as expressions only in the following situations:
The select list of a
SELECT
statement (either a subquery or an outer query).A
HAVING
clause.
For more details seehttps://learn.microsoft.com/en-us/sql/t-sql/functions/aggregate-functions-transact-sql?view=sql-server-ver16
MAX returns NULL when there is no row to select.
MAX ignores any null values.
For more details see https://learn.microsoft.com/en-us/sql/t-sql/functions/max-transact-sql?source=recommendations&view=sql-server-ver16