Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
SQL Distinct | Database & Introduction to Syntax
SQL Tutorial for Beginners
course content

Course Content

SQL Tutorial for Beginners

SQL Tutorial for Beginners

1. Database & Introduction to Syntax
2. SQL Aggregate Functions
3. Filtering Statements

bookSQL Distinct

Distinct is a keyword used with SELECT to return only unique values. Usually, you want to get all unique values, but there are duplicate values stored in the tables.

Check the difference: in our table, there are 18 records at all, and each record has a singer. You'll retrieve the 18 singers with the next query:

12
SELECT singer FROM songs
copy

But some singers, for example, AC/DC, occur multiple times. To retrieve the unique singers, use the DISTINCT keyword before the singer column:

12
SELECT DISTINCT singer FROM songs
copy

Now there are no repeated values, so you can see that the total number of unique singers is 10.

Task

Find all unique title values in songs.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 4
toggle bottom row

bookSQL Distinct

Distinct is a keyword used with SELECT to return only unique values. Usually, you want to get all unique values, but there are duplicate values stored in the tables.

Check the difference: in our table, there are 18 records at all, and each record has a singer. You'll retrieve the 18 singers with the next query:

12
SELECT singer FROM songs
copy

But some singers, for example, AC/DC, occur multiple times. To retrieve the unique singers, use the DISTINCT keyword before the singer column:

12
SELECT DISTINCT singer FROM songs
copy

Now there are no repeated values, so you can see that the total number of unique singers is 10.

Task

Find all unique title values in songs.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 4
toggle bottom row

bookSQL Distinct

Distinct is a keyword used with SELECT to return only unique values. Usually, you want to get all unique values, but there are duplicate values stored in the tables.

Check the difference: in our table, there are 18 records at all, and each record has a singer. You'll retrieve the 18 singers with the next query:

12
SELECT singer FROM songs
copy

But some singers, for example, AC/DC, occur multiple times. To retrieve the unique singers, use the DISTINCT keyword before the singer column:

12
SELECT DISTINCT singer FROM songs
copy

Now there are no repeated values, so you can see that the total number of unique singers is 10.

Task

Find all unique title values in songs.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Distinct is a keyword used with SELECT to return only unique values. Usually, you want to get all unique values, but there are duplicate values stored in the tables.

Check the difference: in our table, there are 18 records at all, and each record has a singer. You'll retrieve the 18 singers with the next query:

12
SELECT singer FROM songs
copy

But some singers, for example, AC/DC, occur multiple times. To retrieve the unique singers, use the DISTINCT keyword before the singer column:

12
SELECT DISTINCT singer FROM songs
copy

Now there are no repeated values, so you can see that the total number of unique singers is 10.

Task

Find all unique title values in songs.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 1. Chapter 4
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
some-alt