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_id | status | country | amount |
|---|---|---|---|
| 1 | paid | US | 50 |
| 2 | refunded | US | 40 |
| 3 | paid | IN | 80 |
| 4 | paid | UK | 90 |
Expected Output
| order_id | amount |
|---|---|
| 1 | 50 |
| 4 | 90 |
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 BYorder is checked by the grader. - Query type: Write a single read-only Standard SQL
SELECT(orWITH ... SELECT) query.
Constraints & Evaluation Criteria
- Return `order_id, amount` ordered by `order_id ASC`.
Hints
SQL⌘/Ctrl+Enter to Run · ⌘/Ctrl+Shift+Enter to Submit
Loading Code Editor...
+1 Hidden Submit Case
Input / Scenario
orders (4 rows)
Expected Output / Criteria
2 row(s): (1, 50); (4, 90)