Find Candidates for Data Scientist Position - Problem
Find the Perfect Data Science Team!
You're a hiring manager at a tech company looking to build an elite data science team. You have a database of candidates and their technical skills, but you need to find those who have all three essential skills for a Data Scientist position.
Given a
Table: Candidates
The combination of
Goal: Return the
You're a hiring manager at a tech company looking to build an elite data science team. You have a database of candidates and their technical skills, but you need to find those who have all three essential skills for a Data Scientist position.
Given a
Candidates table where each row represents a candidate's skill, find all candidates who are proficient in Python, Tableau, and PostgreSQL.Table: Candidates
+--------------+---------+
| Column Name | Type |
+--------------+---------+
| candidate_id | int |
| skill | varchar |
+--------------+---------+
The combination of
(candidate_id, skill) is the primary key.Goal: Return the
candidate_id of candidates who have all three required skills, ordered by candidate_id in ascending order. Input & Output
example_1.sql โ Basic Example
$
Input:
Candidates table:
+---------------+--------------+
| candidate_id | skill |
+---------------+--------------+
| 101 | Python |
| 101 | Tableau |
| 101 | PostgreSQL |
| 102 | Python |
| 102 | Tableau |
| 103 | Python |
| 103 | Tableau |
| 103 | PostgreSQL |
| 104 | Tableau |
+---------------+--------------+
โบ
Output:
+---------------+
| candidate_id |
+---------------+
| 101 |
| 103 |
+---------------+
๐ก Note:
Candidate 101 has all three required skills (Python, Tableau, PostgreSQL). Candidate 102 is missing PostgreSQL. Candidate 103 has all three skills. Candidate 104 only has Tableau.
example_2.sql โ No Qualified Candidates
$
Input:
Candidates table:
+---------------+--------------+
| candidate_id | skill |
+---------------+--------------+
| 201 | Python |
| 201 | Java |
| 202 | Tableau |
| 202 | Excel |
| 203 | PostgreSQL |
| 203 | MySQL |
+---------------+--------------+
โบ
Output:
+---------------+
| candidate_id |
+---------------+
(empty result)
๐ก Note:
No candidate has all three required skills. Each candidate only has one of the required skills along with other non-required skills.
example_3.sql โ Single Qualified Candidate
$
Input:
Candidates table:
+---------------+--------------+
| candidate_id | skill |
+---------------+--------------+
| 301 | Python |
| 301 | Tableau |
| 301 | PostgreSQL |
| 301 | Java |
| 301 | Excel |
| 302 | Python |
| 302 | Java |
+---------------+--------------+
โบ
Output:
+---------------+
| candidate_id |
+---------------+
| 301 |
+---------------+
๐ก Note:
Candidate 301 has all three required skills plus additional skills (Java, Excel). Having extra skills doesn't disqualify them. Candidate 302 only has Python.
Constraints
- 1 โค candidate_id โค 1000
- skill names are case-sensitive strings
- Each (candidate_id, skill) combination is unique
- Required skills are exactly: 'Python', 'Tableau', 'PostgreSQL'
- Table contains 1 to 104 rows
Visualization
Tap to expand
Understanding the Visualization
1
Collect Resumes
Gather all candidate skill records from the database
2
Filter Relevant Skills
Focus only on the three required skills: Python, Tableau, PostgreSQL
3
Group by Candidate
Organize filtered skills by each candidate
4
Count Skills
Count how many required skills each candidate has
5
Select Qualified
Choose candidates with exactly 3 required skills
Key Takeaway
๐ฏ Key Insight: Instead of checking each skill individually with separate queries, count the total required skills per candidate in one efficient GROUP BY operation!
๐ก
Explanation
AI Ready
๐ก Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code