From the course: Microsoft SQL Server 2016: Query Data

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Filtering duplicates with DISTINCT

Filtering duplicates with DISTINCT - SQL Server Tutorial

From the course: Microsoft SQL Server 2016: Query Data

Start my 1-month free trial

Filtering duplicates with DISTINCT

- In this lesson, we're going to take a look at how we can filter duplicates by using the DISTINCT keyword in Transact-SQL. To give an example of where we have multiple values, or sometimes duplicates, sometimes more than duplicates, we'll just do a quick select all from our Person table. And I just want to do this to give you an idea of the number of rows, or the number of records that we actually have in this table representing people. So we have 19,972 rows. Why is it important? Well, in and of itself, not necessarily, but let's say, as an example, I want to take a look at how many different PersonTypes we actually have. This may be representative of the different employee categories or something in a company, and if I highlight and run this query, simply selecting the PersonType column, we see an example of, again, returning 19,972 rows. So we have more than just duplicates. We have multiple values of this same type. So we have multiple EMs, multiple VCs, et cetera. We can scroll…

Contents