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 and failing_rows for two checks: 'orders_without_items' and 'orphan_line_items'. Order by check_name.
Result columns · in this order
check_namefailing_rowsHow to approach it
Write each direction as a LEFT JOIN with an IS NULL filter, count the rows, then UNION ALL them.
Sample input
| order_id | status |
|---|---|
| 1003 | pending |
| 1006 | refunded |
| 1009 | pending |
| 1011 | paid |
| 1012 | shipped |
5 rows — all rows shown.
| order_id | sku |
|---|---|
| 1001 | SKU-A |
| 1002 | SKU-C |
| 1004 | SKU-A |
| 1005 | SKU-F |
| 1007 | SKU-B |
5 rows — all rows shown.
Expected output
| check_name | failing_rows |
|---|---|
| orders_without_items | 5 |
| orphan_line_items | 0 |
2 rows — all rows shown.
Constraints
Use a LEFT JOIN + IS NULL anti-join for each direction, COUNT the failing rows, and UNION ALL the two checks. A clean direction must return 0, not no rows.
Expected skills
Anti-join referential checks and reporting gaps as counts.
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.