From the course: SQL: Data Reporting and Analysis

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Deduplicate with SELECT DISTINCT

Deduplicate with SELECT DISTINCT - SQL Tutorial

From the course: SQL: Data Reporting and Analysis

Deduplicate with SELECT DISTINCT

- [Instructor] Previously, we were introduced to group by and used this with count star to see which values were the most popular in a field. So, this query returned us 378 rows with a sort of frequency value against them. Now we know that there were 603 rows altogether in the table, so what this tells us is, that there are 378 unique values, and sometimes all you need is a list of those unique values. You don't actually need any counting or clever stuff. And for that, we can use select distinct district, and you can see that gives us 378 rows, just unique values there. You can use select distinct on as many fields as you like, actually. If you wrote select distinct, and then every field in the table, for example, then you would simply have a list of all the fields and all the data in the table. So let's say select distinct district and address, and because address is broadly, well, probably unique, we have now 603 rows…

Contents