Write a SQL query that uses window functions to rank vendors by cost savings within each category.
Use the provided vendor and quote data. Cost savings equal benchmark cost minus quoted cost, summed for each vendor and category. Exclude unmatched vendors and quote rows missing either cost.
vendor_id, vendor_name, category, total_cost_savings, and savings_rank.category, savings_rank, then vendor_id.| Column | Type | Description |
|---|---|---|
| vendor_idPK | INT | Unique vendor identifier |
| vendor_name | VARCHAR(100) | Vendor business name |
| Column | Type | Description |
|---|---|---|
| quote_idPK | INT | Unique quote identifier |
| vendor_id | INT | Vendor submitting the quote |
| category | VARCHAR(50) | Procurement category |
| benchmark_cost | NUMERIC(12,2) | Expected or benchmark cost |
| quoted_cost | NUMERIC(12,2) | Cost quoted by the vendor |