Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Return the minimum or maximum of a set of values contained in a specified field on a query.

Syntax

Min( expr )

Max( expr )

The expr placeholder represents a string expression identifying the field that contains the data you want to evaluate or an expression that performs a calculation using the data in that field. Operands in expr can include the name of a table field, a constant, or a function (which can be either intrinsic or user-defined but not one of the other SQL aggregate functions).

Remarks

You can use Min and Max to determine the smallest and largest values in a field based on the specified aggregation, or grouping. For example, you could use these functions to return the lowest and highest freight cost. If there is no aggregation specified, then the entire table is used.

You can use Min and Max in a query expression and in the SQL property of a QueryDef object or when creating a Recordset object based on an SQL query.

Query examples

Expression

Results

SELECT Min(Unitprice) as Expr1 from ProductSales;

Returns the minimum unit price from the field "Unitprice" and displays in the column Expr1.

SELECT Max(Unitprice) as Expr1 from ProductSales;

Returns the maximum unit price from the field "Unitprice" and displays in the column xpr1.

SELECT Max(Unitprice) as MaxPrice from ProductSales;

Returns the maximum unit price from the field "Unitprice" and displays in the column "MaxPrice".

Calculating Fields in SQL Functions

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×