Skip to the content

The workshop hits the road

Problem

The store's workshop for people under 30 is going on the road, and the owner asks which cities it has to stop in: the ones where at least one customer under 30 lives.

Show a single column, the city, in alphabetical order. Each city appears once, even if two customers under 30 live there tomorrow. And if one of them never gave a city, there's nowhere to take the workshop: they shouldn't leave an empty row.

What it has to return

These rows, in this order

city
Austin
Boston
Tampa

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 city
FROM customers
WHERE age < 30
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(log n) challenges

See all challenges →