Your question is Window Functions for Top Records. 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.
Virtusa's delivery portfolio team needs to identify the highest-performing services within selected categories. Write a PostgreSQL query that aggregates completed sales and ranks services independently within the Cloud and Data & AI categories.
| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique service identifier |
| product_name | VARCHAR(120) | Virtusa delivery service name |
| category | VARCHAR(80) | Service category |
| active | BOOLEAN | Whether the service is currently offered |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique sales record identifier |
| product_id | INT | Referenced service, nullable for unassigned sales |
| amount | DECIMAL(12,2) | Sale value |
| status | VARCHAR(20) | Sale processing status |