Review Candidates at Inclusive Salary Boundaries
Find candidates earning from $60,000 through $75,000.
- Filtering
- Sorting
Exercise brief
Understand the request
Candidate compensation analyst A salary-band review must retain candidates at both approved endpoints.
Return candidates earning from $60,000 through $75,000, including both endpoints.
Return
- Return candidate_id, team_code, salary in this exact left-to-right order.
Constraints
- Treat both $60,000 and $75,000 as inclusive boundaries.
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
cohort_candidates
candidate_idINTEGERteam_codeTEXTsalaryDECIMAL
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
An inclusive range keeps rows at both the lower and upper salary boundaries.
Hint 2
Use BETWEEN with the lower value first, then make ordering deterministic for candidates who share a salary.
Hint 3
SELECT candidate_id, team_code, salary FROM cohort_candidates WHERE salary BETWEEN /* inclusive lower */ AND /* inclusive upper */ ORDER BY salary, /* tie breaker */;
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT candidate_id, team_code, salary FROM cohort_candidates WHERE salary BETWEEN 60000 AND 75000 ORDER BY salary, candidate_id;Why this works
BETWEEN is equivalent to `salary >= 60000 AND salary <= 75000`, so the fixture's exact $60,000 and $75,000 rows must be present. Using strict comparisons drops those boundary candidates, while reversing the endpoints returns no rows. Numeric BETWEEN is inclusive across all supported engines; the second sort key makes equal salaries deterministic.
Success check
Every salary is inside the inclusive band and equal salaries have deterministic ordering.
Expected result
Use this output to verify values, aliases, ordering, and row count.
| candidate_id | team_code | salary |
|---|---|---|
| 101 | DATA | 60000 |
| 109 | DATA | 60000 |
| 102 | PLATFORM | 60001 |
| 113 | DATA | 68000 |
| 114 | SALES | 69000 |
| 103 | IT | 70000 |
| 104 | SALES | 70001 |
| 105 | IT | 72000 |
| 111 | SECURITY | 74000 |
| 106 | HR | 75000 |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Build the next SQL skill
SELECT Statements
Select columns, filter rows, remove duplicates, and order query results.
CASE Statements & Conditional Logic
Build NULL-aware classifications, precedence-safe decisions, flags, scores, and guarded calculations with portable CASE expressions.
Date Operations & Time-Based Analytics
Practice date arithmetic, safe timestamp ranges, calendar bucketing, dense time series, rolling windows, growth, and cohort analysis.
Open the interactive workspace and practice across SQL topics.