Explore Library
Quiz

LEFT JOIN with COUNT and GROUP BY

Understanding why COUNT(*) and COUNT(column) differ when aggregating over a LEFT JOIN.

You want the number of orders per customer, including customers with zero orders: SELECT c.customer_id, COUNT(*) AS order_count FROM customers c LEFT JOIN orders o ON o.customer_id = c.customer_id GROUP BY c.customer_id; What is wrong with the reported counts?