Beginner

13. SELECT DISTINCT

Learn how DISTINCT removes duplicate values from SQL query results.

📘 Lesson 13 of 728 ⏱ 7 min 🎯 Beginner

The DISTINCT keyword is used with SELECT to remove duplicate rows from the result returned by a query. When a selected column contains the same value multiple times, DISTINCT returns the value only once. DISTINCT does not delete or modify duplicate records in the original table. It only affects the query result.

DISTINCT is useful when you need to identify unique values in a dataset. Data Analysts commonly use it to find unique departments, cities, product categories, customer types, transaction statuses, and other business categories.

If an Employees table contains thousands of employees but only a small number of departments, DISTINCT can be used to display each department only once.

SQL
SELECT DISTINCT
    Department
FROM Employees;

DISTINCT is used for customer segmentation, department analysis, product analysis, location analysis, transaction analysis, and data-quality investigations.

  • DISTINCT removes duplicate result rows.
  • DISTINCT does not delete records from the table.
  • DISTINCT can be used with one or more columns.
  • DISTINCT is useful for identifying unique values.
  • DISTINCT works with SELECT.
What does DISTINCT do?

DISTINCT removes duplicate rows from the result returned by a SELECT query.

Does DISTINCT delete duplicate records?

No. DISTINCT only removes duplicates from the query result and does not modify the original table.

Have you finished this lesson?

Introduction to SQL – All Lessons