Exercise 28:2010.The Number of Seniors and Juniors to Join the Company II

1.Description

Table: Candidates

+-------------+------+
| Column Name | Type |
+-------------+------+
| employee_id | int  |
| experience  | enum |
| salary      | int  |
+-------------+------+
employee_id is the primary key column for this table.
experience is an enum with one of the values ('Senior', 'Junior').
Each row of this table indicates the id of a candidate, their monthly salary, and their experience.
The salary of each candidate is guaranteed to be unique.

A company wants to hire new employees. The budget of the company for the salaries is $70000. The company's criteria for hiring are:

  1. Keep hiring the senior with the smallest salary until you cannot hire any more seniors.

  2. Use the remaining budget to hire the junior with the smallest salary.

  3. Keep hiring the junior with the smallest salary until you cannot hire any more juniors.

Write an SQL query to find the ids of seniors and juniors hired under the mentioned criteria.

Return the result table in any order.

The query result format is in the following example.

Example 1:

Example 2:

2.Create Table and insert into values

The difference between this question and question 27 is only in the final Query , other steps are the same.

Last updated