返回介绍

solution / 3000-3099 / 3051.Find Candidates for Data Scientist Position / README_EN

发布于 2024-06-17 01:02:57 字数 3018 浏览 0 评论 0 收藏 0

3051. Find Candidates for Data Scientist Position

中文文档

Description

Table: Candidates

+--------------+---------+ 
| Column Name  | Type  | 
+--------------+---------+ 
| candidate_id | int   | 
| skill    | varchar |
+--------------+---------+
(candidate_id, skill) is the primary key (columns with unique values) for this table.
Each row includes candidate_id and skill.

Write a query to find the candidates best suited for a Data Scientist position. The candidate must be proficient in Python, Tableau, and PostgreSQL.

Return _the result table ordered by _candidate_id _in ascending order_.

The result format is in the following example.

 

Example 1:

Input: 
Candidates table:
+---------------+--------------+
| candidate_id  | skill    | 
+---------------+--------------+
| 123       | Python     |
| 234       | R      | 
| 123       | Tableau    | 
| 123       | PostgreSQL   | 
| 234       | PowerBI    | 
| 234       | SQL Server   | 
| 147       | Python     | 
| 147       | Tableau    | 
| 147       | Java     |
| 147       | PostgreSQL   |
| 256       | Tableau    |
| 102       | DataAnalysis |
+---------------+--------------+
Output: 
+--------------+
| candidate_id |  
+--------------+
| 123      |  
| 147      | 
+--------------+
Explanation: 
- Candidates 123 and 147 possess the necessary skills in Python, Tableau, and PostgreSQL for the data scientist position.
- Candidates 234 and 102 do not possess any of the required skills for this position.
- Candidate 256 has proficiency in Tableau but is missing skills in Python and PostgreSQL.
The output table is sorted by candidate_id in ascending order.

Solutions

Solution 1: Conditional Filtering + Grouping Statistics

First, we filter out candidates who have the skills Python, Tableau, and PostgreSQL. Then, we group by candidate_id and count the number of skills each candidate has. Finally, we filter out candidates who have these three skills and sort them in ascending order by candidate_id.

# Write your MySQL query statement below
SELECT candidate_id
FROM Candidates
WHERE skill IN ('Python', 'Tableau', 'PostgreSQL')
GROUP BY 1
HAVING COUNT(1) = 3
ORDER BY 1;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文