Last updated

SQL MIN and MAX

Definition: MIN() returns the smallest value in a column and MAX() the largest. They are aggregate functions — they work across many rows to produce a single answer.

Example 1 — cheapest product price

SELECT MIN(Price) FROM Products;

Example 2 — most expensive price

SELECT MAX(Price) FROM Products;

Example 3 — name the result with AS

By default the column is named after the function. Use AS to give it a friendly name:

SELECT MAX(Price) AS HighestPrice
FROM Products;

Example 4 — both at once

SELECT MIN(Price) AS Cheapest, MAX(Price) AS Dearest
FROM Products;

💡 Tip: MIN and MAX also work on text (alphabetical order) and dates (earliest/latest).

Try it Yourself
Output

          
Ad · responsive