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

Order Status Counts per Customer

For each customer return the number of delivered orders and the number of cancelled orders as two columns. Order by customer_id.

Table schema

Orders(id INT PRIMARY KEY, customer_id INT, status VARCHAR(20))

Sample data

id | customer_id | status
1 | 1 | Delivered
2 | 1 | Cancelled
3 | 1 | Delivered
4 | 2 | Cancelled

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.