Those go, and only those
- O(1) · Trivial
- Free
- SQL
- filtering
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
| name | category | price |
|---|---|---|
| Keyboard | Accessories | 45.5 |
| Monitor | Displays | 189 |
| Laptop | Devices | 899 |
| Tablet | Devices | 320 |
| Headphones | Audio | 59.9 |
| Speaker | Audio | 74 |
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 < 20It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.