How do you approach window and join operations in large-scale SQL queries?
Using the provided PostgreSQL tables, write a query that calculates each restaurant's completed deliveries and most recent completed delivery during January 2025, then ranks restaurants within their city. Include restaurants with no qualifying deliveries.
restaurant_name, city, completed_deliveries, last_completed_at, and city_rank.city, city_rank, and restaurant_id.| Column | Type | Description |
|---|---|---|
| restaurant_idPK | INT | Unique restaurant identifier |
| restaurant_name | VARCHAR(100) | Restaurant display name |
| city | VARCHAR(80) | Restaurant city |
| Column | Type | Description |
|---|---|---|
| delivery_idPK | INT | Unique delivery identifier |
| restaurant_id | INT | Restaurant associated with the delivery |
| status | VARCHAR(30) | Delivery status |
| completed_at | TIMESTAMP | Timestamp when the delivery was completed |