SQL Select Distinct

The `SELECT DISTINCT` statement in SQL is used to return only distinct (different) values from a column. It eliminates duplicate values from the result set.

Syntax

The syntax for using `SELECT DISTINCT` is as follows:

SELECT DISTINCT column1, column2, ...
FROM table_name;

Example

Suppose you have a table named Employees with a column named Department. To get a list of distinct departments from this table, you would use the following query:

SELECT DISTINCT Department
FROM Employees;

This query retrieves unique department names from the Employees table, filtering out any duplicate entries.

Notes

Understanding how to use `SELECT DISTINCT` can help you manage and analyze data more effectively by removing duplicate entries from your query results.