MIN & MAX Functions
Locate extremes (earliest/latest dates, lowest/highest numbers, alphabetical boundaries) with MIN and MAX.
MIN & MAX Functions is an essential topic in SQL and relational database engineering.
Overview
Building on foundational principles introduced in sum-avg-functions, mastering min & max functions provides the core mental model and practical query skills needed for production relational database engineering.
SELECT
MIN(price) AS cheapest_book,
MAX(price) AS most_expensive_book,
MIN(published_date) AS oldest_edition,
MAX(published_date) AS newest_edition
FROM books;
Key Concepts
- Understand the fundamental syntax, conventions, and mental model.
- Avoid common beginner traps, data type mismatches, and performance pitfalls.
- Apply practical idioms directly in production applications.
[!TIP] Master this concept to build a rock-solid foundation. Next, proceed to groupby.