SQL QuestSQL Interview Questions › Querying Basics

DISTINCT Values

EasyFreeQuerying Basics

Find all unique countries that orders have been placed from. Show just the country column with no duplicates. Sort alphabetically. Then, in a second approach, count how many unique countries there are (as country_count).

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

orders

order_idcustomer_idproductcategoryquantitypricetotalorder_datecountrystatus
11Laptop ProElectronics11299.991299.992024-01-15USAcompleted
22Wireless MouseElectronics249.9999.982024-01-16Canadacompleted
33Office ChairFurniture1349.99349.992024-01-17USAcompleted

Expected output: List of unique countries, sorted A-Z

Hint

SELECT DISTINCT country removes duplicate values. For the count: SELECT COUNT(DISTINCT country) AS country_count.

Concepts

SELECT DISTINCT

Practise the topic: SQL practice questions

Related questions

Your First QueryEasy · FreePick Your ColumnsEasy · FreeFilter with WHEREEasy · FreeComparison OperatorsEasy · FreeMultiple Conditions (AND / OR)Easy · FreeThe IN OperatorEasy · Free

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test