easy · ~8 min
The operations dashboard groups historical orders into recency buckets relative to a fixed reference date of 2024-06-30 (2024-06-30 00:00:00).
2024-06-30 00:00:00
Write a query that counts orders in each recency bucket:
bucket
2024-06-30
last_7_days
2024-06-24
last_30_days
2024-06-01
2024-06-23
older
2024-05-31
order_count
Input contract: order_id is unique and non-null; order_date is non-null, always at midnight (00:00:00), and never later than 2024-06-30 00:00:00. Every bucket contains at least one order.
order_id
order_date
00:00:00