SQL Server MAX() Function

Summary: in this tutorial, you will learn how to use the SQL Server MAX() function to find the maximum value in a set.

Introduction to the SQL Server MAX() function #

In SQL Server, the MAX() function is an aggregate function that returns the maximum value in a set.

Here’s the syntax of the MAX() function:

MAX(expression)Code language: SQL (Structured Query Language) (sql)

The MAX() function accepts an expression that can be a column or a valid expression.

Similar to the MIN() function, the MAX() function ignores NULL and considers all values including duplicates.

SQL Server MAX() function examples #

We will use the products and brands tables for the demonstration: