Hire Within Budget — Seniors First
Problem
**[Asked at Uplers]**
You have a hiring budget of **$150 000**. Candidates must be hired in order:
all **Senior** candidates first (by salary ascending), then **Junior**
candidates (by salary ascending).
Find the **name of the last candidate** who can be hired without exceeding
the budget.
Tables
Example rows — the live problem includes the full dataset.
candidates
| candidate_id | name | level | salary |
|---|
Expected output
Your answer should return 1 row with the columns name.
Starter code (SQL)
SELECT *
FROM candidates;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock