SQL SELECT DISTINCT Statement

Redundancy is the repetition of certain data in a table. With the use of DISTINCT clause data redundancy may be avoided. This clause will eliminate the repetitive appearance of same data. DISTINCT can come only once in a given select statement.

Syntax :

SELECT DISTINCT <column_name> 
FROM <table_name> 
WHERE <conditions>;

Parameters :

NameDescription
column_name Name of the column.
table_name Name of the table.
conditions It may be a condition, a select query or an expression.
  • SELECT DISTINCT returns only distinct (different) values.
  • SELECT DISTINCT eliminates duplicate records from the results.
  • DISTINCT can be used with aggregates: COUNT, AVG, MAX, etc.
  • DISTINCT operates on a single column. DISTINCT for multiple columns is not supported.