All problems

The Electronics Aisle

easySQLFiltering

Marketing at Whetcode Supply is putting together an electronics-only promotion email. The template lists the items in a single column with a price beside each, and it opens on the cheapest one — the idea being that a low first number keeps people reading down the page.

The catalogue mixes categories together, so the slice has to be picked out of it. Note that the category labels are stored exactly as they appear in the table, lower case and all.

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, name and price, one row per product in the electronics category, cheapest first. Match the category label exactly as it is stored. No two electronics items share a price, so that single instruction fixes the sequence.

Example output — shape only, on an invented catalogue. If the electronics shelf held two items, you would get:

name price
Cable Tidy 33
Monitor Riser 210

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…