Skip to main content
SQL โ€ข LESSON 130

Recent Orders

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

Advancedโฑ 3 Minutesโญ 1430 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