Category Flagships
The storefront at Whetcode Supply gives every category a hero slot at the top of its page, and the rule the merchandising team settled on is simple: the hero is whatever costs most in that category, because the expensive item sets the tone for everything under it.
What the team wants first is the price alone, one per category, in category order so the page templates can be filled in one pass. The hero's name is a separate job.
products — the catalogue, one row per item on sale. price is what a single unit costs, in dollars.
| id | name | category | price |
|---|---|---|---|
| 1 | Wireless Mouse | electronics | 25.0 |
| 2 | Standing Desk | furniture | 350.0 |
| 3 | Desk Lamp | furniture | 40.0 |
| 4 | Mechanical Keyboard | electronics | 85.0 |
| 5 | Notebook Set | office | 12.0 |
The table already exists in the database — there is nothing to create or load.
Task: Write a query returning two columns, category and flagship_price (the highest price among the items in that category), one row per category that has at least one product, ordered alphabetically by category ascending. Return the price only, not the name of the item that carries it.
Example output — shape only, on invented figures. The category labels are the real stored ones, and only the price comes back, never the item carrying it:
| category | flagship_price |
|---|---|
| electronics | 210 |
| furniture | 640 |
| office | 18 |
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in