Skip to main content
SQL • LESSON 130

Recent Orders

How can we retrieve orders from the last 30 days dynamically?

Advanced3 Minutes1430 XP
🤔 THE QUESTION

How can we retrieve orders from the last 30 days dynamically?

💡 WHAT IS IT?

Subtracting INTERVAL '30' DAY from CURRENT_DATE filters for trailing rolling-window periods.

🎯 WHAT IS IT USED FOR?

Last 30 days dashboard widgets, active customer tracking, recent SLA compliance.

💻 EXAMPLE
SELECT *
FROM orders
WHERE order_date >= CURRENT_DATE - INTERVAL '30' DAY;

🎯 Mission Objectives

Practice typing production-grade SQL code for Recent Orders.

  • CURRENT_DATE
  • INTERVAL arithmetic
  • Rolling window filter
  • Dynamic time filtering