Basics & SELECT Queries · SQL SQL

Consider a table named employees with a column salary. Which query correctly retrieves all rows where the salary is between 40000 and 60000 inclusive?

Practice question from Basics & SELECT Queries (SQL SQL), with the correct answer and a step-by-step solution.

medium · MCQ · Q-01886C

Consider a table named employees with a column salary. Which query correctly retrieves all rows where the salary is between 40000 and 60000 inclusive?

  1. A.SELECT * FROM employees WHERE salary BETWEEN 40000 AND 60000;Correct answer
  2. B.SELECT * FROM employees WHERE salary > 40000 AND < 60000;
  3. C.SELECT * FROM employees WHERE salary IN (40000, 60000);
  4. D.SELECT * FROM employees WHERE salary RANGE 40000 TO 60000;

Solution

The BETWEEN operator in SQL is inclusive of both boundary values. Option B is syntactically invalid, option C checks for exact matches, and option D is not standard SQL.

More from Basics & SELECT Queries

All of Basics & SELECT Queries

Practise more SQL

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed