Skip to the content

Arriving Wednesday

Problem

The store delivers in three business days: the count starts the day after the order is placed, and neither Saturday nor Sunday counts. Something ordered on a Monday arrives on Thursday; something ordered on a Saturday arrives on Wednesday.

The '%w' format of STRFTIME gives the day of the week as text from '0' to '6', and '0' is Sunday.

Show three columns: each order's number, its date, and the day it gets delivered. The earliest deliveries go on top and, when the day is the same, the lower order number goes first.

Orders dated up to today, January 15, 2026, are included. The one dated the 20th stays out: with a mistyped date, there's no day to promise.

What it has to return

These rows, in this order

idplacedarrives
12026-01-032026-01-07
22026-01-042026-01-07
32026-01-042026-01-07
42026-01-092026-01-14
52026-01-102026-01-14
62026-01-112026-01-14
72026-01-122026-01-15
82026-01-122026-01-15
92026-01-142026-01-19
102026-01-152026-01-20
112026-01-152026-01-20

This is what comes out with the data in the practice database this challenge uses. The column names don’t count, so name yours however you like: what counts is how many there are and the order they come in. Besides this one, the challenge has hidden tests with other data that are revealed when you submit your solution.

You start with this

SQL

SELECT id, placed,
  DATE(placed, '+3 days') AS arrives
FROM orders
ORDER BY arrives, id;
Solve this challenge

It opens in your browser, with the editor and the tests. This challenge is part of the full plan; the O(1) and O(log n) ones are free.

More O(n²) challenges

See all challenges →