Beginner

191. DISTINCT

Learn how DISTINCT removes duplicate combinations from SQL query results.

📘 Lesson 191 of 728 ⏱ 8 min 🎯 Beginner

The DISTINCT keyword returns only unique rows from the selected columns. Duplicate combinations of the selected column values are removed from the result.

Business data often contains repeated values, and analysts frequently need a unique list of departments, cities, customers, or categories.

Find the unique departments available in the Employees table.

SQL
SELECT DISTINCT
    Department
FROM Employees;

DISTINCT is useful for creating unique lists, identifying categories, checking data quality, and preparing analysis.

  • DISTINCT removes duplicate result rows.
  • It applies to the selected columns.
  • Multiple columns are evaluated together.
  • It can be useful for data exploration.
  • DISTINCT does not remove records from the table.
What does DISTINCT do?

DISTINCT returns only unique combinations of the selected columns.

Does DISTINCT delete duplicate data?

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

Have you finished this lesson?

Introduction to SQL – All Lessons