Filter Orders With AND & IN Conditions

Basics
BasicsWHEREINGoogleAmazonMeta

Table

  • orders(order_id INT, status VARCHAR, country VARCHAR, amount INT)

Task

From orders(order_id, status, country, amount), return order_id and amount for orders where status = 'paid' AND country is 'US' or 'UK', ordered by order_id ASC.

Why It Matters: Combining AND with IN (...) cleanly filters multi-condition production order tables without verbose chains of OR clauses.

Output columns: order_id, amount

Example

Input — orders

order_idstatuscountryamount
1paidUS50
2refundedUS40
3paidIN80
4paidUK90

Expected Output

order_idamount
150
490

Explanation: Filters rows matching both the status allowlist (IN (...)) and the numeric threshold (AND), ordered deterministically.

Requirements

  • Exact output columns: order_id, amount
  • Row order: Exact ORDER BY order is checked by the grader.
  • Query type: Write a single read-only Standard SQL SELECT (or WITH ... SELECT) query.

Constraints & Evaluation Criteria

  • Return `order_id, amount` ordered by `order_id ASC`.

Hints

SQL
Loading Code Editor...
+1 Hidden Submit Case
Input / Scenario
orders (4 rows)
Expected Output / Criteria
2 row(s): (1, 50); (4, 90)