A ticket by text
- O(log n) · Easy
- Free
- SQL
- nulls
- filtering
Problem
The store is raffling off a Tablet. In Denver and in Boston, tickets are handed out at each city's street fair. Every other customer gets a ticket by text message, and so does anyone who never gave a city, since there's no telling whether a fair is anywhere near them.
The raffle is for adults only: you're in if you're 18 or older, and with no age on file there's no ticket.
Show the name and the age of everyone who gets a ticket by text, in that order.
What it has to return
These rows, in any order
| name | age |
|---|---|
| Luke | 27 |
| Chloë | 41 |
| Mason | 19 |
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, age
FROM customers
WHERE city NOT IN
('Denver', 'Boston')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(log n) challenges
- Each aisle gets its own discountSQL · conditionals · operations · decimals
- Not passed yetSQL · conditionals · nulls
- Room for one badgeSQL · conditionals
- The display case backupSQL · sorting · filtering
- The eighties, the ninetiesSQL · operations · sorting
- The last night counts tooSQL · operations · conditionals