返回介绍

solution / 2000-2099 / 2041.Accepted Candidates From the Interviews / README_EN

发布于 2024-06-17 01:03:11 字数 3705 浏览 0 评论 0 收藏 0

2041. Accepted Candidates From the Interviews

中文文档

Description

Table: Candidates

+--------------+----------+
| Column Name  | Type   |
+--------------+----------+
| candidate_id | int    |
| name     | varchar  |
| years_of_exp | int    |
| interview_id | int    |
+--------------+----------+
candidate_id is the primary key (column with unique values) for this table.
Each row of this table indicates the name of a candidate, their number of years of experience, and their interview ID.

 

Table: Rounds

+--------------+------+
| Column Name  | Type |
+--------------+------+
| interview_id | int  |
| round_id   | int  |
| score    | int  |
+--------------+------+
(interview_id, round_id) is the primary key (combination of columns with unique values) for this table.
Each row of this table indicates the score of one round of an interview.

 

Write a solution to report the IDs of the candidates who have at least two years of experience and the sum of the score of their interview rounds is strictly greater than 15.

Return the result table in any order.

The result format is in the following example.

 

Example 1:

Input: 
Candidates table:
+--------------+---------+--------------+--------------+
| candidate_id | name  | years_of_exp | interview_id |
+--------------+---------+--------------+--------------+
| 11       | Atticus | 1      | 101      |
| 9      | Ruben   | 6      | 104      |
| 6      | Aliza   | 10       | 109      |
| 8      | Alfredo | 0      | 107      |
+--------------+---------+--------------+--------------+
Rounds table:
+--------------+----------+-------+
| interview_id | round_id | score |
+--------------+----------+-------+
| 109      | 3    | 4   |
| 101      | 2    | 8   |
| 109      | 4    | 1   |
| 107      | 1    | 3   |
| 104      | 3    | 6   |
| 109      | 1    | 4   |
| 104      | 4    | 7   |
| 104      | 1    | 2   |
| 109      | 2    | 1   |
| 104      | 2    | 7   |
| 107      | 2    | 3   |
| 101      | 1    | 8   |
+--------------+----------+-------+
Output: 
+--------------+
| candidate_id |
+--------------+
| 9      |
+--------------+
Explanation: 
- Candidate 11: The total score is 16, and they have one year of experience. We do not include them in the result table because of their years of experience.
- Candidate 9: The total score is 22, and they have six years of experience. We include them in the result table.
- Candidate 6: The total score is 10, and they have ten years of experience. We do not include them in the result table because the score is not good enough.
- Candidate 8: The total score is 6, and they have zero years of experience. We do not include them in the result table because of their years of experience and the score.

Solutions

Solution 1

# Write your MySQL query statement below
SELECT candidate_id
FROM
  Candidates AS c
  LEFT JOIN Rounds AS r ON c.interview_id = r.interview_id
WHERE years_of_exp >= 2
GROUP BY c.interview_id
HAVING SUM(score) > 15;

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

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

发布评论

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