Decode Analytics

View Original

Select Distinct

The DISTINCT keyword can be used to return only distinct (unique) values. It is often used to remove duplicates from query results.

SQL Select DISTINCT Syntax:

SELECT DISTINCT

Column1,

Column2,

Column3

FROM Table_Name

Example:

Lets get the distinct ReasonTypes from the following table.

See this content in the original post

Results:

See this content in the original post

Distinct can be used with aggregates COUNT, AVG, MAX, etc.

SELECT COUNT

(DISTINCT Column1)

FROM Table_Name



Ex:

See this content in the original post


Results:

See this content in the original post

SQL Tutorial

See this content in the original post