Skip to the content

Those go, and only those

Problem

Shipping costs 10, and nobody pays that for an accessory that costs less than shipping it twice. The owner is taking the accessories under 20 off the site, and only those: an accessory at 20 or more stays, and anything that isn't an accessory stays whatever it costs.

Show the name, the category, and the price of what's still on the site, in that order.

What it has to return

These rows, in any order

namecategoryprice
KeyboardAccessories45.5
MonitorDisplays189
LaptopDevices899
TabletDevices320
HeadphonesAudio59.9
SpeakerAudio74

This is what comes out with the data in the practice database this challenge uses. The column names don’t count, so name yours however you like: what counts is how many there are and the order they come in. Besides this one, the challenge has hidden tests with other data that are revealed when you submit your solution.

You start with this

SQL

SELECT name, category, price
FROM products
WHERE category = 'Accessories'
  AND price < 20
Solve this challenge

It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.

More O(1) challenges

See all challenges →