Beginner

157. DISTINCT Keyword

Learn how DISTINCT removes duplicate combinations from SQL query results.

📘 Lesson 157 of 728 ⏱ 8 min 🎯 Beginner

DISTINCT tells SQL to return only unique combinations of the selected expressions in the result set.

Business datasets often contain repeated values. DISTINCT can help identify unique categories, departments, locations, or other attributes.

An analyst can use DISTINCT to find all unique departments in an Employees table.

SQL
SELECT DISTINCT
    Department
FROM Employees;

DISTINCT is commonly used for unique customer locations, product categories, departments, statuses, and other business classifications.

  • DISTINCT removes duplicate result combinations.
  • It applies to the selected expressions.
  • It does not modify the underlying table.
  • Multiple columns can be used with DISTINCT.
  • DISTINCT may require additional processing for large datasets.
What does DISTINCT do?

DISTINCT returns only unique combinations of the selected values in the result set.

Does DISTINCT delete duplicate rows from a table?

No. DISTINCT only removes duplicates from the query result; it does not change the stored data.

Have you finished this lesson?

Introduction to SQL – All Lessons