Level 3 - IntermediateDebugging Questions
Debugging: LEFT JOIN Dropping Rows
Interviewer prompt: Query should return all customers and paid order count, but customers without paid orders are missing. Fix it. SELECT c.id, COUNT(o.id) AS paid_orders FROM customers c LEFT JOIN orders o ON c.id = o.customer_id WHERE o.status = 'PAID' GROUP BY c.id;
Schema Context
customers(id), orders(id, customer_id, status)