Practice · SQL · easy

Data Science Skills

Find candidates who have every required skill: Python, Tableau and PostgreSQL.

Question

Given a table of candidates and their skills, list the candidates qualified for an open Data Science role. A qualified candidate has all of these skills: Python, Tableau, and PostgreSQL. Sort the result by candidate_id in ascending order.

Assume there are no duplicate rows in the candidates table.

candidates table

ColumnType
candidate_idinteger
skillvarchar

Example input

candidate_idskill
123Python
123Tableau
123PostgreSQL
234R
234PowerBI
234SQL Server
345Python
345Tableau

Expected output

candidate_id
123

Solution

SELECT candidate_id
FROM candidates
WHERE skill IN ('Python', 'Tableau', 'PostgreSQL')
GROUP BY candidate_id
HAVING COUNT(DISTINCT skill) = 3
ORDER BY candidate_id ASC;

What this demonstrates

  • WHERE filters eligible skill rows before GROUP BY.
  • COUNT(DISTINCT skill) counts how many required skills each candidate has.
  • HAVING keeps only candidates whose distinct required-skill count is three.