🔧 Quick Syntax
SELECT MAX(column_name)
FROM table_name;
This tells SQL:
“Go through this column and tell me the biggest value you see.”
🧾 Here’s the Table You’re Working With
Your table is called orders
:
order_id | customer_name | total_amount |
---|---|---|
1 | Fenn Rask | 10.00 |
2 | Milo Kresh | 45.00 |
3 | Sora Dune | 15.99 |
4 | Lexa Vohn | 72.50 |
5 | Tovi Glint | 29.99 |
✅ Suppose You Want the Highest Order Value
SELECT MAX(total_amount)
FROM orders;
💡 Output:
72.50
SQL checked the total_amount
column and gave you the largest value it found — Lexa’s big order.
✅ MAX() Works with Dates Too
If your table had an order_date
column, you could find the most recent order like this:
SELECT MAX(order_date)
FROM orders;
SQL would return the latest date — perfect for dashboards and time-based reports.
✅ Suppose You Want the Max From Orders Below $50
SELECT MAX(total_amount)
FROM orders
WHERE total_amount < 50;
💡 Output:
45.00
SQL filtered the rows first, then told you the max from the remaining group. Efficient and flexible.
🧃 Recap – What You Learned
MAX()
finds the largest value in a column- Works with numbers, dates, and text
NULL
values are skipped- Use
WHERE
to apply conditions before finding the max - Great for top sales, latest activity, or biggest scores