DISTINCT keyword
SELECT DISTINCT
is used to return only distinct (i.e different) values from a
column as part of a SELECT statement.
Syntax
Examples
The following query will return a list of all unique ratings in the table.
Simple query
SELECT DISTINCT movieId
FROM ratings;
SELECT DISTINCT can be used in conjunction with more advanced queries and filters.
With aggregate
SELECT DISTINCT movieId, count()
FROM ratings;
With filter
SELECT DISTINCT movieId, count()
FROM ratings
WHERE score > 3;