All problems

What's Our Priciest Item?

easySQLSorting

A shopper has written in to Whetcode Supply's support desk asking what the most expensive thing in the catalogue is, and the agent answering wants to check rather than guess. She needs the product's name and its price in the same answer.

The largest price on its own would not settle it — a price with no product attached tells the shopper nothing. What has to come back is the row that holds that price, name included.

products — one row per product on sale. price is 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 a single row with two columns, name and price, for the most expensive product in the catalogue. Exactly one row comes back.

Example output — shape only, on an invented product and price.

name price
Monitor Arm 129

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

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…