SQLRepPath
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
00/60 solved

The Basics · SELECT DISTINCT

6. Countries with active customers

Concept: SELECT DISTINCTshow

SELECT DISTINCT removes duplicate rows from the result, so each value comes back once. It applies to the whole row: SELECT DISTINCT a, b keeps one row per unique (a, b) pair, not per a.

Example (different data):

SELECT DISTINCT city
FROM stores
WHERE is_open = true
ORDER BY city;

Your task

The localization team needs the list of countries where we still have active customers, to decide which languages to support.

Return each country that has at least one active customer, once, as a single column country, sorted alphabetically.

Solution unlocks after 3 more tries

Starting Postgres in your browser…

query.sql
Output

Write a query and press Run Query (Ctrl/⌘ + Enter).