CODE WORKSPACE

Filter January's bigger orders

Return order_id, status, and total_amount for orders that are paid or shipped, were created in January 2026, and have total_amount of at least 100. Order by order_id.

Filter on status IN ('paid','shipped'), a half-open January range on created_at, and total_amount >= 100, then ORDER BY order_id.

Sample input

ordersA slice of the 12 orders, showing rows that pass and rows excluded by status, amount, or month.
order_idstatustotal_amountcreated_at
1001paid802026-01-12 08:40:00
1002paid1202026-01-12 10:02:00
1003pending402026-01-13 11:15:00
1004shipped2202026-01-15 14:20:00
1005paid5402026-01-18 09:05:00
1008shipped1502026-01-25 12:00:00
1010paid6402026-01-30 21:10:00
1011paid1102026-02-02 09:00:00

Expected output

Expected outputOnly January paid/shipped orders of $100+. 1001 (under $100), 1003 (pending), and 1011 (February) are dropped.
order_idstatustotal_amount
1002paid120
1004shipped220
1005paid540
1008shipped150
1010paid640

Constraints

Use IN for the status set. Use a half-open date range (created_at >= '2026-01-01' AND created_at < '2026-02-01') so the February orders are excluded. Keep the status set grouped so precedence is unambiguous.

Expected skills

Membership filters with IN, half-open date ranges on text timestamps, and combining AND conditions without precedence bugs.

SQL
Loading...

AI evaluation

Run the SQL query to inspect preview rows.