Find Candidates for Data Scientist Position - Problem

You are given a table Candidates containing candidate information with their skills. Your task is to find candidates who are qualified for a Data Scientist position.

A candidate is qualified if they have all three required skills:

  • Python
  • Tableau
  • PostgreSQL

Return the result ordered by candidate_id in ascending order.

Table Schema

Candidates
Column Name Type Description
candidate_id PK int Unique identifier for each candidate
skill PK varchar Skill possessed by the candidate
Primary Key: (candidate_id, skill)
Note: Each row represents one skill for a candidate. A candidate can have multiple skills across multiple rows.

Input & Output

Example 1 — Basic Candidate Filtering
Input Table:
candidate_id skill
101 Java
101 Python
101 MySQL
101 PostgreSQL
101 Tableau
102 Python
102 MySQL
103 Python
103 PostgreSQL
Output:
candidate_id
101
💡 Note:

Candidate 101 has all three required skills (Python, Tableau, PostgreSQL) plus additional skills. Candidate 102 only has Python, and candidate 103 has Python and PostgreSQL but missing Tableau.

Example 2 — Multiple Qualified Candidates
Input Table:
candidate_id skill
201 Python
201 Tableau
201 PostgreSQL
202 Python
202 Tableau
202 PostgreSQL
202 R
203 Python
203 Java
Output:
candidate_id
201
202
💡 Note:

Both candidates 201 and 202 have all three required skills. Candidate 202 has an additional R skill. Candidate 203 is missing Tableau and PostgreSQL. Results are ordered by candidate_id.

Example 3 — No Qualified Candidates
Input Table:
candidate_id skill
301 Python
301 Java
302 Tableau
302 Excel
303 PostgreSQL
303 MySQL
Output:
candidate_id
💡 Note:

No candidate has all three required skills. Each candidate is missing at least two of the required skills for the Data Scientist position.

Constraints

  • 1 ≤ candidate_id ≤ 1000
  • skill is a non-empty string
  • Skills are case-sensitive
  • A candidate may have duplicate skill entries

Visualization

Tap to expand
Find Candidates for Data Scientist PositionAll Candidatescandidate_idskill101Python101Tableau101PostgreSQL101Java102Python102MySQLFilter &Group ByGrouped by Skills Countcandidate_idrequired_skillsqualified10131021HAVINGCOUNT = 3Final Resultcandidate_id101✓ Required: Python, Tableau, PostgreSQL✗ Other skills ignored
Understanding the Visualization
1
Filter
Keep only required skills (Python, Tableau, PostgreSQL)
2
Group
Group by candidate_id
3
Count
Select candidates with all 3 skills
Key Takeaway
🎯 Key Insight: Use GROUP BY with HAVING to filter aggregated results - perfect for 'all of these conditions' requirements
Asked in
Amazon 28 Microsoft 22 Meta 18 Google 15
34.2K Views
Medium Frequency
~12 min Avg. Time
987 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen