Your question is SQL Orders Count Per Customer. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Dayforce needs a customer-level order count for a QA validation report. Write a PostgreSQL query that returns every customer and the total number of orders associated with that customer, including customers who have placed no orders.
LEFT JOIN from customers to orders so customers without orders remain in the result.COUNT(*), so unmatched customers receive a count of zero.order_count.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer display name |
| created_at | DATE | Date the customer record was created |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| customer_id | INT | Customer associated with the order |
| order_date | DATE | Date the order was placed |