Beginner

428. JOIN with MIN and MAX

Learn how MIN and MAX can identify the lowest and highest values in joined datasets.

📘 Lesson 428 of 728 ⏱ 11 min 🎯 Intermediate

MIN returns the smallest value and MAX returns the largest value within the selected joined data.

Minimum and maximum values help analysts identify ranges, extremes, earliest dates, latest dates, and performance boundaries.

Find the highest and lowest order amount for each customer.

SQL
SELECT
    c.CustomerName,
    MIN(o.OrderAmount) AS MinimumOrder,
    MAX(o.OrderAmount) AS MaximumOrder
FROM Customers c
INNER JOIN Orders o
    ON c.CustomerID = o.CustomerID
GROUP BY c.CustomerName;

MIN and MAX with JOIN are useful for transaction analysis, customer behavior, salary analysis, and date-based reporting.

  • MIN returns the smallest value.
  • MAX returns the largest value.
  • Both can be used with joined data.
  • They can be grouped by business entities.
  • They are useful for range and boundary analysis.
What do MIN and MAX return?

MIN returns the smallest value and MAX returns the largest value in the selected data.

Can MIN and MAX be used with JOIN?

Yes. They can calculate minimum and maximum values across related joined records.

Have you finished this lesson?

Introduction to SQL – All Lessons