SQL
Lab
LinkedIn Easy Group By Skills

Data
Science
Skills

Find candidates who have all three required skills for a Data Science role: Python, Tableau, and PostgreSQL.

Table Schema

Inspect
Table

interactive
ColumnTypeDescription
candidate_idintegerUnique candidate identifier.
skillvarcharA skill listed on the candidate profile.

Sample Data

Input
Output

Sample Input: candidates
candidate_idskill
123Python
123Tableau
123PostgreSQL
234R
234PowerBI
234SQL Server
345Python
345Tableau
Expected Output
candidate_id
123

SQL Editor

Run
Query

postgresql
Waiting for query

candidate_id
123

Hints

Unlock
Clues

Hint 01: First, filter rows to Python, Tableau, and PostgreSQL.
Hint 02: Group the filtered rows by candidate_id.
Hint 03: A qualified candidate has COUNT(skill) = 3, then order by candidate_id ASC.

Solution

Locked
Answer

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

Step By
Step

01

Filter to the three skills required for the Data Science role.

02

Group by candidate_id so each candidate becomes one group of matching skills.

03

Use HAVING COUNT(skill) = 3 to keep candidates with all required skills, then sort ascending.

Related Questions

Keep
Solving