문제 1. Data Science Skills
Given a table of candidates and their skills, you're tasked with finding the candidates best suited for an open Data Science job. You want to find candidates who are proficient in Python, Tableau, and PostgreSQL.
Write a query to list the candidates who possess all of the required skills for the job. Sort the output by candidate ID in ascending order.
https://datalemur.com/questions/matching-skills
LinkedIn SQL Interview Question | DataLemur
LinkedIn SQL Interview Question: Write a query to find candidates with matching skills.
datalemur.com
💡 문제 풀이
`내 풀이`
소요 시간 08:00
- 정답은 맞았는데 COUNT(candidate_id)= 3이 오류의 여지가 있을 것 같다.
SELECT candidate_id
FROM candidates
WHERE skill IN ('Python', 'Tableau', 'PostgreSQL')
GROUP BY candidate_id
HAVING COUNT(candidate_id) = 3
ORDER BY candidate_id ASC;
`더 나은 풀이`
- HAVING 조건을 제대로 걸기
SELECT candidate_id
FROM candidates
WHERE skill IN ('Python', 'Tableau', 'PostgreSQL')
GROUP BY candidate_id
HAVING COUNT(candidate_id) = 3 -- 각 후보자가 정확히 3개 기술(Python, Tableau, PostgreSQL)있는 경우만 선택
ORDER BY candidate_id ASC;
💯결과