Sign in to run and submit your work
Reading is open to everyone. Running code and saving drafts need an account so your work is yours and comes back on your next visit.
or
CODE WORKSPACE
Return check_name, failing_rows, and status for four checks: duplicate_snapshot_keys, orders_without_items, missing_country_customers, and orphan_line_items. Order by check_name.
Result columns · in this order
check_namefailing_rowsstatusHow to approach it
Build each check as a counted subquery, stack them with UNION ALL, then label pass/fail with CASE.
Sample input
| order_id | updated_at |
|---|---|
| 1001 | 2026-01-12 09:00:00 |
| 1001 | 2026-01-13 10:00:00 |
| 1004 | 2026-01-15 14:30:00 |
| 1004 | 2026-01-16 12:20:00 |
4 rows — all rows shown.
| customer_id | country |
|---|---|
| 1 | US |
| 2 | null |
| 3 | GB |
3 rows — all rows shown.
Expected output
| check_name | failing_rows | status |
|---|---|---|
| duplicate_snapshot_keys | 2 | fail |
| missing_country_customers | 1 | fail |
| orders_without_items | 5 | fail |
| orphan_line_items | 0 | pass |
4 rows — all rows shown.
Constraints
Compute each check as a scalar COUNT subquery, UNION ALL them into one set of (check_name, failing_rows), then add status via CASE WHEN failing_rows = 0 THEN 'pass' ELSE 'fail' END.
Expected skills
Composing named checks into a reproducible audit evidence table.
Submit for review to find out what your query gets right, what it gets wrong, and how it compares with the best working query for this exercise.
This scenario runs a full workspace — editor, canvas and results side by side. It needs a laptop or desktop to be usable. Open this page on a bigger screen to start building.