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?
Given a table Employees with a column
Department containing values: 'Sales', 'HR', 'Sales', 'IT', 'HR', what will this query return?SELECT DISTINCT Department FROM Employees;
SQL
SELECT DISTINCT Department FROM Employees;
Attempts:
2 left
💡 Hint
DISTINCT removes duplicate values and shows only unique ones.
✗ Incorrect
The DISTINCT keyword returns only unique values from the Department column, so duplicates like 'Sales' and 'HR' appear once.
❓ query_result
intermediate2:00remaining
How many rows does this DISTINCT query return?
Consider a table Orders with a column
What is the number of rows returned by this query?
CustomerID having values: 1, 2, 2, 3, 1, 4.What is the number of rows returned by this query?
SELECT DISTINCT CustomerID FROM Orders;
SQL
SELECT DISTINCT CustomerID FROM Orders;
Attempts:
2 left
💡 Hint
Count unique CustomerID values only.
✗ Incorrect
The unique CustomerIDs are 1, 2, 3, and 4, so the query returns 4 rows.
📝 Syntax
advanced2:00remaining
Which query correctly uses DISTINCT to get unique city names?
You want to get unique city names from the Customers table's
City column. Which query is correct?Attempts:
2 left
💡 Hint
DISTINCT comes right after SELECT and before column names.
✗ Incorrect
The correct syntax places DISTINCT immediately after SELECT, before the column name.
❓ optimization
advanced2:00remaining
Which query is more efficient to get unique product categories?
You want to list unique product categories from the Products table. Which query is more efficient?
Attempts:
2 left
💡 Hint
DISTINCT is designed to return unique values directly.
✗ Incorrect
SELECT DISTINCT is optimized to return unique values without grouping overhead.
🧠 Conceptual
expert2:00remaining
What error occurs when using DISTINCT with multiple columns incorrectly?
Consider this query:
What happens if you try to use DISTINCT on only one column but select multiple columns without specifying DISTINCT properly?
SELECT DISTINCT Name, Age FROM Employees WHERE Age > 30;
What happens if you try to use DISTINCT on only one column but select multiple columns without specifying DISTINCT properly?
Attempts:
2 left
💡 Hint
DISTINCT applies to the entire row, not just one column.
✗ Incorrect
DISTINCT returns unique rows considering all selected columns together, not individually.