Skip to main contentSkip to solution

Which of the following SQL command is correct to select the name (Ename) and department number (DeptId) of all those employees from the relation 'EMPLOYEE' who are earning Salary between 20000 and 50000 (both values inclusive)?

Solution

✅ Correct Option: 3

"Both values inclusive" means salaries of exactly 20000 and exactly 50000 must be included. So both bounds need the inclusive operators >=>= and <=<=, which is what Option 3 uses: Salary>=20000 AND Salary<=50000. This is the same as Salary BETWEEN 20000 AND 50000, since BETWEEN in SQL includes both end values.


Option 1: excludes 20000, because it uses >> for the lower bound.

Option 2: excludes both 20000 and 50000.

Option 4: the conditions are reversed. No salary can be ≤20000\le 20000 and ≥50000\ge 50000 at the same time, so it returns no rows.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question