A merchandising team wants to see how each product ranks by price within its category. Using the products table, return category, name, price, and a price_rank column that gives each product's rank within its category (1 = most expensive). Order the result by category ascending, then price_rank ascending.
products
| column | type |
|---|---|
| id | INTEGER |
| name | TEXT |
| category | TEXT |
| price | NUMERIC |
| id | name | category | price |
|---|---|---|---|
| 1 | Pro Headphones | Electronics | 299.99 |
| 2 | USB Cable | Electronics | 9.99 |
| 3 | Wireless Mouse | Electronics | 49.99 |
| 4 | Leather Wallet | Accessories | 79.99 |
| 5 | Cotton Tote | Accessories | 24.99 |
| 6 | Silk Scarf | Accessories | 119.99 |
| category | name | price | price_rank |
|---|---|---|---|
| Accessories | Silk Scarf | 119.99 | 1 |
| Accessories | Leather Wallet | 79.99 | 2 |
| Accessories | Cotton Tote | 24.99 | 3 |
| Electronics | Pro Headphones | 299.99 | 1 |
| Electronics | Wireless Mouse | 49.99 | 2 |
| Electronics | USB Cable | 9.99 | 3 |
Within Accessories, Silk Scarf is the most expensive (rank 1), followed by Leather Wallet (rank 2) and Cotton Tote (rank 3). The ranking resets to 1 for Electronics, where Pro Headphones is the most expensive. The result is sorted by category then by rank within each category.