Room for one badge
- O(log n) · Easy
- Free
- SQL
- conditionals
Problem
On the store's website there's room for a single badge next to each product, but several products qualify for two. Here's what takes priority: if there are no units left, Sold out, and there's nothing more to say. If fewer than 6 are left, Few left, which is more urgent than any promotion. Otherwise, if it costs 100 or more, Free shipping.
Everything else gets Available.
Show each product's name and its badge, in that order.
What it has to return
These rows, in any order
| name | badge |
|---|---|
| Keyboard | Available |
| Mouse | Available |
| Monitor | Few left |
| Cable | Sold out |
| Laptop | Few left |
| Tablet | Free shipping |
| Headphones | Available |
| Speaker | Sold out |
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
FROM productsIt opens in your browser, with the editor and the tests. It is free and you do not need an account to start.