Return Unique Values Using SQL DISTINCT

By Hemanta Sundaray on 2022-12-13

When we are examining data in a table, it can be helpful to know what distinct values exist in a particular column.

DISTINCT is used to return unique values in the output. It filters out all duplicate values in the specified column(s).

For example, it is easier to see the different possible genres in a movie table after the data has been filtered than to scan every row in the table.

SELECT DISTINCT genre
FROM movies;

Join the Newsletter