From the course: Oracle Database 12c: Basic SQL

Unlock the full course today

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

Using DISTINCT to eliminate duplicates

Using DISTINCT to eliminate duplicates - Oracle Database Tutorial

From the course: Oracle Database 12c: Basic SQL

Start my 1-month free trial

Using DISTINCT to eliminate duplicates

- [Narrator] We can use the distinct keyword as part of your sequel query to filter out duplicate rows. Let's start with a very simple query. Let's say we want to see all of the distinct department id values that we have in our employees table. Simply typing select department id from employees and running the query, produced us with a list of all department id values we see a lot of duplicates. As you can see, for example, department id 50 repeats multiple times. That's because each department has multiple employees assigned to that department. For example, department id 50 has multiple employees assigned to it, so we see this value repeats multiple time in our query, not a very convenient way to see all of the distinct department id values we have in our employees table. We can fix that by simply adding the distinct keyword between our select keyword and the list of table columns. Using distinct as part of our sequel query will filter out any duplicate values in the data that is…

Contents