🔧 Quick Syntax
SELECT MIN(column_name)
FROM table_name;
This tells SQL:
“Go through this column and tell me the smallest value you can find.”
It works with numbers, dates, even text (alphabetically).
🧾 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 to Find the Lowest Order Amount
SELECT MIN(total_amount)
FROM orders;
💡 Output:
10.00
SQL checked every value in the total_amount
column and gave you the smallest one.
✅ MIN() Also Works with Dates
If your table had a created_at
or order_date
column, you could find the earliest date like this:
SELECT MIN(order_date)
FROM orders;
This would return the oldest date in the column.
✅ Suppose You Want the Lowest Total from Orders Over $30
SELECT MIN(total_amount)
FROM orders
WHERE total_amount > 30;
💡 Output:
45.00
SQL looked at only the rows where total_amount
is over 30, and gave you the lowest from that group.
🧃 Recap – What You Learned
MIN()
gives you the smallest value in a column- Works with numbers, dates, and text
- Ignores
NULL
values - Use
WHERE
to find the min in a filtered subset - Great for finding lowest totals, first events, earliest times, etc.