Skip to main contentSkip to solution

What will the following SQL query return?

SELECT DISTINCT DeptId from EMPLOYEE;

Solution

✅ Correct Option: 1

DISTINCT removes duplicate values from the result. The query lists every different DeptId in EMPLOYEE once, so no DeptId repeats in the output.


Option 2: DISTINCT does not filter out NULLs. If NULL exists in DeptId, it appears once in the result. Removing NULLs needs WHERE DeptId IS NOT NULL.

Option 3: a count needs an aggregate function such as COUNT(DeptId) or COUNT(DISTINCT DeptId).

Option 4: choosing records by a condition needs a WHERE clause, which this query does not have.

Keyboard Shortcuts

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