Table Schema
Inspect
Table
| Column | Type | Description |
|---|---|---|
| candidate_id | integer | Unique candidate identifier. |
| skill | varchar | A skill listed on the candidate profile. |
Find candidates who have all three required skills for a Data Science role: Python, Tableau, and PostgreSQL.
Table Schema
| Column | Type | Description |
|---|---|---|
| candidate_id | integer | Unique candidate identifier. |
| skill | varchar | A skill listed on the candidate profile. |
Sample Data
| candidate_id | skill |
|---|---|
| 123 | Python |
| 123 | Tableau |
| 123 | PostgreSQL |
| 234 | R |
| 234 | PowerBI |
| 234 | SQL Server |
| 345 | Python |
| 345 | Tableau |
| candidate_id |
|---|
| 123 |
SQL Editor
| candidate_id |
|---|
| 123 |
Hints
Solution
Solution is locked until you decide to reveal it. Try the editor first, then open this when you want the reference answer.
SELECT
candidate_id
FROM candidates
WHERE skill IN ('Python', 'Tableau', 'PostgreSQL')
GROUP BY candidate_id
HAVING COUNT(skill) = 3
ORDER BY candidate_id ASC;Explanation
Filter to the three skills required for the Data Science role.
Group by candidate_id so each candidate becomes one group of matching skills.
Use HAVING COUNT(skill) = 3 to keep candidates with all required skills, then sort ascending.
Related Questions