Recall & Review
beginner
What does the SQL keyword DISTINCT do?
It removes duplicate rows from the result set, showing only unique values for the selected columns.
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 without duplicates.Click to reveal answer
intermediate
Can DISTINCT be used with multiple columns?
Yes, it returns unique combinations of the specified columns. For example,
SELECT DISTINCT city, country FROM Customers; shows unique city-country pairs.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 applied before or after sorting in a query?
DISTINCT is applied before sorting. The database first removes duplicates, then sorts the results if ORDER BY is used.
Click to reveal answer
What does the SQL keyword DISTINCT do?
✗ Incorrect
DISTINCT removes duplicate rows, showing only unique values.
Which query returns unique countries from the table Customers?
✗ Incorrect
SELECT DISTINCT country FROM Customers; returns unique country names.
If you use DISTINCT on two columns, what do you get?
✗ Incorrect
DISTINCT on multiple columns returns unique combinations of those columns.
What will happen if all values in a column are already unique and you use DISTINCT?
✗ Incorrect
If all values are unique, DISTINCT does not change the result.
When is DISTINCT applied in the order of query operations?
✗ Incorrect
DISTINCT is applied before ORDER BY sorting.
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 DISTINCT is used with multiple columns in a SELECT statement.
Imagine filtering unique pairs instead of single values.
You got /3 concepts.