UPDATESQL

Unit 4, lesson 6 · Unit 4 challenge

Unit 4 review: dates

Unit 4 challenge: the late-delivery report

This challenge uses everything from this unit: a month label with to_char, a date moved by adding days, and a gap in days by subtracting dates. Build one column at a time and check a row by hand: count the days on a calendar for one late order and make sure your days_late agrees.

Example
SELECT id, order_date, delivered_date,
       delivered_date - order_date AS days_to_deliver
FROM orders
WHERE status = 'delivered'
ORDER BY days_to_deliver DESC
LIMIT 5;

Your task

Northwind Gear promises delivery within 7 days of the order. For delivered orders placed from October 1, 2026 onward that arrived after that promise, return the id, the order_month (like '2026-10'), the order_date, the promised_by date (7 days after the order), the delivered_date and how many days late it was as days_late.

Tables you will use: orders

Try it in your browserFree, no sign-up. Your query is checked as you go.