Consider the following 'EMPLOYEE' table.
EmpNo Salary DepID 1 19000 D1 2 20000 D2 3 21000 D1 4 35000 D2
Which statement is used to select details of all employees except those working in DepID D1?
Consider the following 'EMPLOYEE' table.
| EmpNo | Salary | DepID |
|---|---|---|
| 1 | 19000 | D1 |
| 2 | 20000 | D2 |
| 3 | 21000 | D1 |
| 4 | 35000 | D2 |
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.
Related questions:
2026: 26 May Shift 1
2025: 15 May Shift 2
2025: 13 May Shift 2
2025: 13 May Shift 2