title sidebar_label description
DISTINCT keyword DISTINCT DISTINCT SQL keyword reference documentation.

SELECT DISTINCT is used to return only distinct (i.e different) values from a column as part of a SELECT statement.

Syntax

Flow chart showing the syntax of the DISTINCT keyword

Examples

The following query will return a list of all unique ratings in the table.


1. SELECT DISTINCT movieId
2. FROM ratings;

SELECT DISTINCT can be used in conjunction with more advanced queries and filters.


1. SELECT DISTINCT movieId, count()
2. FROM ratings;


1. SELECT DISTINCT movieId, count()
2. FROM ratings
3. WHERE score > 3;