Your question is Window Functions SQL Query. Start with the requirements and the three 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.
Eli Lilly’s commercial analytics team wants to compare completed prescription revenue for Lilly products across U.S. regions. Write a PostgreSQL query that ranks products within each region for the first quarter of 2025.
2025-01-01 through 2025-03-31.| Column | Type | Description |
|---|---|---|
| region_idPK | INT | Unique sales region identifier |
| region_name | VARCHAR(50) | U.S. sales region name |
| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique Lilly product identifier |
| product_name | VARCHAR(100) | Lilly product name |
| therapeutic_area | VARCHAR(100) | Product therapeutic category |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique prescription sales record identifier |
| region_id | INT | References regions.region_id |
| product_id | INT | References products.product_id |
| sale_date | DATE | Prescription record date |
| net_revenue | DECIMAL(12,2) | Net revenue in U.S. dollars |
| status | VARCHAR(20) | Processing status of the record |