Challenge - 5 Problems
Distinct Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of this DISTINCT query?
Consider a table Employees with a column
Department containing values: 'Sales', 'HR', 'Sales', 'IT', 'HR'. What will this query return?SELECT DISTINCT Department FROM Employees;
MySQL
SELECT DISTINCT Department FROM Employees;
Attempts:
2 left
💡 Hint
DISTINCT removes repeated values and shows each unique value once.
✗ Incorrect
The DISTINCT keyword returns only unique values from the Department column, so duplicates like repeated 'Sales' or 'HR' are shown once.
🧠 Conceptual
intermediate1:30remaining
Which statement about DISTINCT is true?
Choose the correct statement about the DISTINCT keyword in SQL.
Attempts:
2 left
💡 Hint
Think about what DISTINCT does to repeated data.
✗ Incorrect
DISTINCT removes duplicate rows considering all columns in the SELECT list, not just one column or only numeric data.
📝 Syntax
advanced1:30remaining
Which query correctly uses DISTINCT to get unique city names?
Given a table
Customers with a column City, which query correctly returns unique city names?Attempts:
2 left
💡 Hint
DISTINCT comes right after SELECT.
✗ Incorrect
The correct syntax is SELECT DISTINCT column FROM table. Other options have wrong keyword order or unsupported keywords.
❓ optimization
advanced2:00remaining
Which query is more efficient to get unique product categories?
You want to list unique product categories from a large
Products table. Which query is more efficient?Attempts:
2 left
💡 Hint
DISTINCT and GROUP BY can both get unique values, but one is simpler and often faster.
✗ Incorrect
SELECT DISTINCT is simpler and usually more efficient than GROUP BY when only unique values are needed without aggregation.
🔧 Debug
expert2:30remaining
Why does this query return duplicates despite DISTINCT?
Given a table
Orders with columns OrderID, CustomerID, and OrderDate, why does this query return duplicate CustomerIDs?SELECT DISTINCT CustomerID, OrderDate FROM Orders;
Attempts:
2 left
💡 Hint
DISTINCT looks at the whole row, not just one column.
✗ Incorrect
DISTINCT considers all columns in the SELECT list. If CustomerID repeats with different OrderDates, rows are unique and all show.