Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Customers With Order Counts (Including Zero)

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.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.