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.
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.