Your question is Top Merchants With Ranking. 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.
DoorDash Marketplace analytics needs a ranked view of high-performing merchants for January 2025. Write an efficient PostgreSQL query that filters valid transactions, aggregates merchant performance, and ranks qualifying merchants within each cuisine.
merchant_name, cuisine, qualifying_transactions, total_revenue, and cuisine_rank, ordered by cuisine and rank.| Column | Type | Description |
|---|---|---|
| merchant_idPK | INT | Unique merchant identifier |
| merchant_name | VARCHAR(100) | DoorDash merchant name |
| cuisine | VARCHAR(50) | Cuisine category |
| is_active | BOOLEAN | Whether the merchant is active |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| merchant_id | INT | Merchant associated with the transaction |
| transaction_date | DATE | Date the transaction occurred |
| status | VARCHAR(20) | Transaction processing status |
| amount | NUMERIC(10,2) | Transaction amount in dollars |