SQL 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:
12SELECT singer FROM songs
But some singers, for example, AC/DC, occur multiple times. To retrieve the unique singers, use the DISTINCT keyword before the singer
column:
12SELECT DISTINCT singer FROM songs
Now there are no repeated values, so you can see that the total number of unique singers
is 10.
Swipe to start coding
Find all unique title
values in songs
.
Рішення
Дякуємо за ваш відгук!
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Сумаризуйте цей розділ
Пояснити код у file
Пояснити, чому file не вирішує завдання
Awesome!
Completion rate improved to 4.17
SQL 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:
12SELECT singer FROM songs
But some singers, for example, AC/DC, occur multiple times. To retrieve the unique singers, use the DISTINCT keyword before the singer
column:
12SELECT DISTINCT singer FROM songs
Now there are no repeated values, so you can see that the total number of unique singers
is 10.
Swipe to start coding
Find all unique title
values in songs
.
Рішення
Дякуємо за ваш відгук!
Awesome!
Completion rate improved to 4.17single