SELECT DISTINCT
Return distinct department IDs from employees.
- Distinct values
Exercise brief
Understand the request
People analytics specialist The dashboard filter needs the unique list of department IDs currently in use.
Show each unique department_id that appears in the employees table, with no duplicates. (There are 4 unique departments represented.)
Return
- Return department_id only.
Constraints
- Remove duplicates with DISTINCT.
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
employees
department_idINTEGER
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
DISTINCT removes duplicate result rows. It belongs immediately after SELECT.
Hint 2
Syntax: SELECT DISTINCT <column> FROM <table>;
Hint 3
Place DISTINCT immediately after SELECT and project only the department identifier.
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT DISTINCT department_id FROM employees;Why this works
DISTINCT collapses identical rows into one. Without it, this query would return 10 rows (one per employee) with department_id values repeating. With it, you get 4 rows — one for each department any employee belongs to.
Success check
Each department_id used by employees appears exactly once.
Expected result
Use this output to verify values, aliases, ordering, and row count.
| department_id |
|---|
| 10 |
| 20 |
| 30 |
| 40 |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Build the next SQL skill
WHERE Clause & Filtering
Practice SQL WHERE clauses with realistic boundary, NULL, text, date, exclusion, and production-filtering problems.
Basic SQL Functions
Practice production-oriented string cleanup, numeric transformations, NULL handling, tolerant conversion, and delimiter parsing.
ORDER BY & Sorting
Practice deterministic SQL ordering with tie-breakers, custom priorities, NULL placement, expressions, joined data, aggregates, and portable top-N patterns.
Open the interactive workspace and practice across SQL topics.