Discussion
For the SQL query given below :
SELECT employee_name
FROM employee
WHERE salary BETWEEN 70000 and 130000
Select the equivalent in SQL without BETWEEN operator :
Answer: C
The equivalent query uses salary \(\gt\)= 70000 and salary \(\lt\)= 130000.
SQL's BETWEEN is inclusive: salary BETWEEN 70000 and 130000 is true for 70000 and for 130000 as well as for every value between them. So the rewrite needs greater-than-or-equal and less-than-or-equal.
Option A uses strict inequalities and drops the two end values. Option B asks for a salary equal to both numbers at once, which no row satisfies, and option D asks for a salary below 70000 and above 130000 together, which is also impossible.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development