SQLRepPath
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
00/60 solved

The Basics · IN · BETWEEN

7. First-week shipments

Concept: IN · BETWEENshow

IN checks a value against a list: status IN ('a', 'b') is shorthand for status = 'a' OR status = 'b'. BETWEEN x AND y checks a range and includes both ends, which makes it handy for date ranges.

Example (different data):

SELECT id, priority, opened_on
FROM tickets
WHERE priority IN ('high', 'urgent')
  AND opened_on BETWEEN '2024-03-01' AND '2024-03-31';

Your task

The warehouse is auditing everything that shipped in the first week of July (July 1 to 7, both included). Refunded orders never shipped; completed and pending ones did.

Return id, customer_id, amount, status and order_date of every completed or pending order dated 2024-07-01 to 2024-07-07 inclusive, sorted by order_date.

Solution unlocks after 3 more tries

Starting Postgres in your browser…

query.sql
Output

Write a query and press Run Query (Ctrl/⌘ + Enter).