You are given two tables: Candidates and Rounds.
The Candidates table contains information about job candidates including their ID, name, years of experience, and interview ID.
The Rounds table contains the scores for each round of interviews, with each row representing one interview round score.
Write a SQL query to find the IDs of candidates who meet both criteria:
- Have at least 2 years of experience
- Their total interview score is strictly greater than 15
Return the result in any order.
Table Schema
| Column Name | Type | Description |
|---|---|---|
candidate_id
PK
|
int | Primary key, unique candidate identifier |
name
|
varchar | Candidate's name |
years_of_exp
|
int | Years of work experience |
interview_id
|
int | Interview identifier |
| Column Name | Type | Description |
|---|---|---|
interview_id
PK
|
int | Interview identifier, foreign key to Candidates |
round_id
PK
|
int | Round number within interview |
score
|
int | Score achieved in this round |
Input & Output
| candidate_id | name | years_of_exp | interview_id |
|---|---|---|---|
| 11 | Alyce | 3 | 101 |
| 12 | Bob | 1 | 102 |
| 13 | Charlie | 2 | 103 |
| interview_id | round_id | score |
|---|---|---|
| 101 | 1 | 8 |
| 101 | 2 | 9 |
| 102 | 1 | 12 |
| 103 | 1 | 10 |
| 103 | 2 | 6 |
| candidate_id |
|---|
| 11 |
| 13 |
Alyce (ID 11): 3 years experience ≥ 2 ✓, total score = 8 + 9 = 17 > 15 ✓
Bob (ID 12): 1 year experience < 2 ✗ (filtered out by WHERE clause)
Charlie (ID 13): 2 years experience ≥ 2 ✓, total score = 10 + 6 = 16 > 15 ✓
| candidate_id | name | years_of_exp | interview_id |
|---|---|---|---|
| 21 | David | 4 | 201 |
| 22 | Eve | 2 | 202 |
| interview_id | round_id | score |
|---|---|---|
| 201 | 1 | 7 |
| 201 | 2 | 8 |
| 202 | 1 | 20 |
| candidate_id |
|---|
| 22 |
David (ID 21): 4 years experience ≥ 2 ✓, but total score = 7 + 8 = 15, which is NOT > 15 ✗
Eve (ID 22): 2 years experience ≥ 2 ✓, total score = 20 > 15 ✓
| candidate_id | name | years_of_exp | interview_id |
|---|---|---|---|
| 31 | Frank | 1 | 301 |
| interview_id | round_id | score |
|---|---|---|
| 301 | 1 | 20 |
| candidate_id |
|---|
Frank (ID 31): Only 1 year experience < 2 ✗ (filtered out despite high score of 20)
Constraints
-
1 ≤ candidate_id ≤ 1000 -
1 ≤ years_of_exp ≤ 10 -
1 ≤ interview_id ≤ 500 -
1 ≤ round_id ≤ 10 -
0 ≤ score ≤ 20