Skip to main contentSkip to solution

Consider the following 'EMPLOYEE' table.

EmpNoSalaryDepID
119000D1
220000D2
321000D1
435000D2

Which statement is used to select details of all employees except those working in DepID D1?

Solution

✅ Correct Option: 1

NOT IN ('D1') keeps every row whose DepID is not D1, so it returns employees 2 and 4 (both in D2).


Option 2: IN ('D1') selects only the D1 employees, which is the opposite of what is asked.

Option 3: SQL has no CONTAINS operator for this kind of comparison, so the statement is invalid. LIKE is used for pattern matching.

Option 4: NOT IN ('D1','D2') excludes both departments, so it returns no rows from this table.

Keyboard Shortcuts

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