D8LooPFocus modeCODE WORKSPACE
Return check_name and failing_rows for two checks: 'orders_without_items' and 'orphan_line_items'. Order by check_name.
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 |
| order_id | sku |
|---|---|
| 1001 | SKU-A |
| 1002 | SKU-C |
| 1004 | SKU-A |
| 1005 | SKU-F |
| 1007 | SKU-B |
Expected output
| check_name | failing_rows |
|---|---|
| orders_without_items | 5 |
| orphan_line_items | 0 |
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.
Run the SQL query to inspect preview rows.