The DISTINCT
keyword is used to return only unique values from a column, removing any duplicates in the results.
If you want to see all the different ages that appear in the students
table, you can use:
SELECT DISTINCT age FROM students;
This returns each age only once, even if multiple students share the same age.
You can also use DISTINCT
with multiple columns to return unique combinations of values:
SELECT DISTINCT name, age FROM students;
This will show only unique name-age pairs from the table.