Your question is SQL Top 3 Per Region. Start with the requirements and the four 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.
Henry Schein wants a regional view of product demand to support inventory planning across its distribution network. Use completed sales orders from the last completed quarter, defined here as Q4 2025.
Write a PostgreSQL query that returns the top three products by total units sold within each region from October 1 through December 31, 2025.
status = 'completed' and order dates within Q4 2025, including both boundary dates.| Column | Type | Description |
|---|---|---|
| region_idPK | INT | Unique region identifier |
| region_name | VARCHAR(50) | Distribution region name |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique sales order identifier |
| region_id | INT | Region associated with the order |
| order_date | DATE | Date the order was placed |
| status | VARCHAR(20) | Order processing status |
| Column | Type | Description |
|---|---|---|
| order_item_idPK | INT | Unique order line identifier |
| order_id | INT | Related sales order identifier |
| product_id | INT | Product sold on the order line |
| quantity | INT | Number of units sold |
| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique product identifier |
| product_name | VARCHAR(100) | Product display name |
| product_sku | VARCHAR(30) | Stock keeping unit |