Customers With Order Counts (Including Zero)
Easy
Join Types Deep Dive
Return every customer with the number of orders they placed, including customers with none (count 0). Order by name.
Table schema
Customers(id INT PRIMARY KEY, name VARCHAR(20))
Orders(id INT PRIMARY KEY, customer_id INT)Sample data
Customers
id | name
1 | Ann
2 | Bob
3 | Cy
Orders
id | customer_id
1 | 1
2 | 1
3 | 3
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.