Orders per customer
mediumShow every customer id and their order count, including customers without an order. Sort by customer id.
Hospital Database · SQLite
Run your SQL answer to see the returned rows and check it.
SELECT c.customer_id, c.first_name, c.last_name, COUNT(o.order_id) AS order_count FROM customers AS c LEFT JOIN orders AS o ON o.customer_id = c.customer_id GROUP BY c.customer_id ORDER BY c.customer_id;