What will the following SQL query return?
SELECT DISTINCT DeptId from EMPLOYEE;
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.
Related questions:
2026: 11 May Shift 2
2026: 29 May Shift 1
2026: 26 May Shift 1