Skip to the content

Where there's more than one

Problem

The store wants to open a pickup location in every city where it has more than one customer. For a single customer it isn't worth it.

Show the city and how many customers live there, in that order. Nothing is known about the people who never said where they live: however many there are, together they don't make a city.

What it has to return

These rows, in any order

cityhow_many
Austin2
Denver3

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
GROUP BY city
Solve this challenge

It opens in your browser, with the editor and the tests. This challenge is part of the full plan; the O(1) and O(log n) ones are free.

More O(n) challenges

See all challenges →