Home / SQL / Practice problems / Easy

Customers per country

Easyrow order matters

Show each country and its number of customers, the largest first.

Tables: customers(customer_id, name, city, country, joined) · products(product_id, name, category, price) · orders(order_id, customer_id, order_date, status) · order_items(order_id, product_id, quantity, unit_price)

Your query
Show the expected result
countrycustomers
Australia12
Nepal4
United Kingdom3
New Zealand1

4 rows

Show a solution
SELECT country, COUNT(*) AS customers FROM customers GROUP BY country ORDER BY customers DESC, country;

SQL used

New to SQL? The free SQL course teaches everything these problems use, with a self-checking exercise in every lesson.