SQL Server Interview Question #85
What do MIN() and MAX() do?
Aggregate Functions, GROUP BY & Window Functions Mid-Level Intermediate
Detailed Explanation
MIN returns the smallest value and MAX returns the largest value in the qualifying set. They work with numeric, date/time, and many comparable character data types.
They are commonly used for lowest/highest prices, earliest/latest dates, minimum/maximum identifiers, and grouped reporting.
Code Example
SELECT CategoryId,
MIN(Price) AS LowestPrice,
MAX(Price) AS HighestPrice
FROM dbo.Products
GROUP BY CategoryId;