Tsallaka zuwa abun ciki
Justice Tech School

SELECT DISTINCT

DISTINCT returns each different value only once. It works on the combination of all selected columns.

Example
SELECT DISTINCT country
FROM students;

Result

country
Nigeria
Ghana
Kenya
South Africa
Example
SELECT COUNT(DISTINCT country) AS countries
FROM students;

Result

countries
4

Exercise

Return each country only once.

SELECT  country FROM students;

Quiz Test

What does DISTINCT do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.