AI Hints
Homeโ€บSQL Tutorialโ€บPractice Gym: The Basics
SQL ยท Lesson 117 of 126

Gym: Dates

One date challenge.

โฑ 2 min readโ–ถ Video at 2:47:15๐ŸŽ“ Free
Watch this lesson in the SQL courseWatch on YouTube โ†—Full SQL course

Dates are stored as text, written year, month, day. That's why comparing them works. One quick challenge.

Gym: Dates
From the video: Gym: Dates
  • Dates are text
  • Year-month-day
  • Comparisons just work

Shipped in December

How many orders from December twenty twenty five still have the status shipped? Pause and try. Here's a solution. Two conditions, the status, and a date on or after the first of December. Five orders are still on their way.

โœ๏ธ Exercise: Shipped in December

Orders from Dec 2025 that are still 'shipped'

Show hint

status = 'shipped' AND order_date >= '2025-12-01'

Show solution
solution.sqlsql
SELECT COUNT(*) AS shipped_in_december
FROM orders
WHERE status = 'shipped'
  AND order_date >= '2025-12-01';
Output
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ shipped_in_december โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 5                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Summary

The basics gym is done. Next, a workout for grouping and joins.

Key takeaways
  • Dates compare as text
  • Combine with AND
  • Basics done
Next up: Practice Gym: Groups and Joins โ€” the middle of the course