SELECT with Multiple Conditions
Return employees in department 10 with salary between 60000 and 90000.
- Filtering
Exercise brief
Understand the request
HR analytics manager The staffing review is looking only at IT employees whose salary falls within the target band.
Find employees in the IT department (department_id = 10) whose salary falls between $60,000 and $90,000 inclusive. Show first_name, last_name, salary, and department_id.
Return
- Return first_name, last_name, salary, and department_id.
Constraints
- Use multiple conditions in the WHERE clause.
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
employees
first_nameVARCHAR(50)last_nameVARCHAR(50)salaryINTEGERdepartment_idINTEGER
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
Both conditions must be true at the same time → use AND, not OR.
Hint 2
BETWEEN x AND y is inclusive on both sides. It is shorthand for `>= x AND <= y`.
Hint 3
WHERE salary BETWEEN 60000 AND 90000 AND department_id = 10
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT first_name, last_name, salary, department_id FROM employees WHERE salary BETWEEN 60000 AND 90000 AND department_id = 10;Why this works
AND requires every condition to be true for the row to pass. BETWEEN is inclusive — both endpoints qualify. The expected answer is 3 employees (Alice, Bob, Grace) — all in IT with salaries inside that range.
Expected result
Use this output to verify values, aliases, ordering, and row count.
| first_name | last_name | salary | department_id |
|---|---|---|---|
| Alice | Johnson | 85000 | 10 |
| Bob | Wilson | 80000 | 10 |
| Grace | White | 90000 | 10 |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Build the next SQL skill
WHERE Clause & Filtering
Practice SQL WHERE clauses with realistic boundary, NULL, text, date, exclusion, and production-filtering problems.
Basic SQL Functions
Practice production-oriented string cleanup, numeric transformations, NULL handling, tolerant conversion, and delimiter parsing.
ORDER BY & Sorting
Practice deterministic SQL ordering with tie-breakers, custom priorities, NULL placement, expressions, joined data, aggregates, and portable top-N patterns.
Open the interactive workspace and practice across SQL topics.