DISTINCT Keyword
Question
What does SELECT DISTINCT do?
Hint
DISTINCT considers all selected columns for uniqueness.
Explanation
SELECT DISTINCT removes duplicate rows from the result set, returning only unique rows. SELECT DISTINCT department FROM employees returns each department once. DISTINCT considers all selected columns together — SELECT DISTINCT city, country returns unique city-country combinations. DISTINCT can impact performance because it requires sorting or hashing to identify duplicates. For counting unique values: SELECT COUNT(DISTINCT column). DISTINCT is often used with GROUP BY or as an alternative to it.
Related Resources
Related Lessons
- SELECT
Learn SELECT.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.