WHERE Clause & Filtering SQL Topic exerciseEasyVerified answerSQLite + PostgreSQL + MySQL + SQL Server live · 1 guided

Audit Candidates Across Numeric Boundaries

Find the approved audit slice for candidates 102 through 109: compensation above $60,000 and capped at $75,000.

  • Filtering

Exercise brief

Understand the request

Candidate audit analyst A reconciliation sample is limited by both candidate identifier and salary boundaries.

Return candidates 102–109 who fall inside the approved compensation band.

Return

  • Return candidate_id, team_code, salary in this exact left-to-right order.

Constraints

  • Include ID 102 but exclude ID 110; exclude $60,000 but include $75,000.

Data you will use

Review the relevant tables before deciding how to join, filter, or aggregate them.

cohort_candidates

  • candidate_idINTEGER
  • team_codeTEXT
  • salaryDECIMAL

Hints, when you need them

Open one clue at a time so you still do the reasoning.

Hint 1

Translate “from” into an inclusive lower ID boundary, “through 109” into an exclusive upper boundary of 110, “above” into a strict comparison, and “at most” into an inclusive comparison.

Hint 2

Combine the two candidate_id comparisons and two salary comparisons with AND.

Hint 3

SELECT candidate_id, team_code, salary FROM cohort_candidates WHERE candidate_id /* inclusive lower */ 102 AND candidate_id /* exclusive upper */ 110 AND salary /* strict lower */ 60000 AND salary /* inclusive upper */ 75000;

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 candidate_id >= 102 AND candidate_id < 110 AND salary > 60000 AND salary <= 75000;

Why this works

The ID window uses `>= 102` and `< 110`, while the salary band uses `> 60000` and `<= 75000`. The fixture includes rows exactly at 102, 110, 60000, and 75000, so changing any boundary operator changes the result. Row order is deliberately not graded because this exercise assesses numeric filtering only.

Success check

Only candidates inside both numeric windows are returned; row order is not assessed.

Expected result

Use this output to verify values, aliases, ordering, and row count.

candidate_idteam_codesalary
102PLATFORM60001
103IT70000
104SALES70001
105IT72000
106HR75000

Learn the concepts behind this answer

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Practice Online

Open the interactive workspace and practice across SQL topics.