Junior — Middle
What is the function of the DISTINCT keyword in SQL queries?
sobes.tech AI
Answer from AI
The keyword DISTINCT in SQL is used to select unique values from a column or set of columns. It excludes duplicates in the result set.
For example, if a table has multiple records with the same value in the "city" column, the query
SELECT DISTINCT city FROM customers;
will return a list of unique cities without repetitions.
This is useful when you need to obtain a list of unique elements rather than all records.