SQL Practice Logo

SQLPractice Online

Level 2 - JuniorDebugging Questions

Debugging: GROUP BY Mismatch

Interviewer prompt: The query throws an aggregate/grouping error. Find the bug type and provide corrected SQL. SELECT c.name, COUNT(o.id) AS total_orders FROM customers c JOIN orders o ON c.id = o.customer_id GROUP BY c.id;

Schema Context

customers(id, name), orders(id, customer_id)