Write a query using window functions to find the top three most-ordered food items for each city on a monthly basis.
Use completed orders only and treat ordered quantity as the ranking measure. Return only the top three items per city and month.
city, month, food_item, total_quantity, and item_rank.city, month, item_rank, then food_item.| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| city | VARCHAR(100) | City where the order was placed |
| order_date | DATE | Date when the order was placed |
| status | VARCHAR(30) | Order fulfillment status |
| Column | Type | Description |
|---|---|---|
| order_item_idPK | INT | Unique order line identifier |
| order_id | INT | Referenced order |
| food_item_id | INT | Referenced food item |
| quantity | INT | Number of units ordered |
| Column | Type | Description |
|---|---|---|
| food_item_idPK | INT | Unique food item identifier |
| food_name | VARCHAR(120) | Food item name |