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).
SELECT tools FROM inventory;
DISTINCT before the column name,
SELECT DISTINCT tools FROM inventory;
the result would now be:
Filtering the results of a query is an important skill in SQL. It is easier to see the different possible
genres in the
movie table after the data has been filtered than to scan every row in the table.
Let’s try it out. In the code editor, type:
SELECT DISTINCT genre FROM movies;
What are the unique genres?
Now, change the code so we return the unique values of the
year column instead.