Recall & Review
beginner
What does the SQL keyword
DISTINCT do?It removes duplicate rows from the result set, showing only unique values.
Click to reveal answer
beginner
How would you select unique city names from a table called
Customers?Use
SELECT DISTINCT city FROM Customers; to get only unique city names.Click to reveal answer
intermediate
Can
DISTINCT be used on multiple columns?Yes, it returns unique combinations of the specified columns.
Click to reveal answer
beginner
What happens if you use
DISTINCT on a column with all unique values?The result will be the same as a normal SELECT because all values are already unique.
Click to reveal answer
intermediate
Is
DISTINCT case sensitive when filtering unique values?It depends on the database collation settings, but usually it is case insensitive in MySQL by default.
Click to reveal answer
What does
SELECT DISTINCT do in SQL?✗ Incorrect
DISTINCT filters the result set to show only unique rows, without duplicates.
Which query returns unique combinations of
city and state from Customers?✗ Incorrect
Only SELECT DISTINCT city, state FROM Customers; returns unique pairs of city and state.
If a column has all unique values, what effect does
DISTINCT have?✗ Incorrect
DISTINCT will return the same rows because all values are already unique.
Can
DISTINCT be used on multiple columns at once?✗ Incorrect
DISTINCT works on multiple columns to return unique combinations of their values.
Is
DISTINCT case sensitive in MySQL by default?✗ Incorrect
MySQL's default collation usually makes DISTINCT case insensitive.
Explain how the
DISTINCT keyword works in SQL and give an example query.Think about how you would find unique items in a list.
You got /3 concepts.
Describe what happens when you use
DISTINCT on multiple columns in a SELECT statement.Consider how two columns together create a unique pair.
You got /3 concepts.