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?
- A.SELECT * FROM employees WHERE salary BETWEEN 40000 AND 60000;Correct answer
- B.SELECT * FROM employees WHERE salary > 40000 AND < 60000;
- C.SELECT * FROM employees WHERE salary IN (40000, 60000);
- 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
- Which of the following clauses is evaluated first during the logical execution of a standard SQL SELECT query?
- What is the primary purpose of the DISTINCT keyword in a SELECT statement?
- How does SQL handle NULL values when comparing them with standard comparison operators like equals (=) or not equals (<>) in a WHERE clause?
- Which of the following clauses is used to filter rows after aggregate functions have been computed?
Practise more SQL
Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.
Start practising freeFree to start · No credit card needed