Beginner

341. DISTINCT Values

Learn how to return only unique values from a SQL query.

📘 Lesson 341 of 728 ⏱ 8 min 🎯 Beginner

The DISTINCT keyword removes duplicate combinations from the selected result columns and returns only unique rows.

DISTINCT is useful when you need to understand unique categories, locations, departments, customers, or other business values.

Find all unique departments available in the Employees table.

SQL
SELECT DISTINCT
    Department
FROM Employees;

Data Analysts use DISTINCT to explore categories, validate data, identify unique business values, and prepare summary lists.

  • DISTINCT removes duplicate result rows.
  • It can be used with one or multiple columns.
  • It does not change the original table.
  • It is useful for data exploration.
  • DISTINCT can require additional processing on large datasets.
What does DISTINCT do?

DISTINCT removes duplicate rows from the query result and returns unique combinations of the selected columns.

Does DISTINCT delete duplicate data from a table?

No. DISTINCT only removes duplicates from the query result; it does not modify the underlying table.

Have you finished this lesson?

Introduction to SQL – All Lessons