Skip to main contentSkip to solution

To select distinct salaries of the employees in a department number D001, what should be the sequence of the statement to construct a correct query?

(A) WHERE Deptid = 'D001'

(B) FROM EMPLOYEE

(C) DISTINCT Salary

(D) SELECT

Solution

✅ Correct Option: 2

A SQL query follows the order SELECT, then the column list, then FROM, then WHERE. DISTINCT comes right after SELECT, so the full query is:

SELECT DISTINCT Salary FROM EMPLOYEE WHERE Deptid = 'D001'

(D) SELECT

(C) DISTINCT Salary

(B) FROM EMPLOYEE

(A) WHERE Deptid = 'D001'

DISTINCT is part of the SELECT clause, not a separate clause, and WHERE always comes after FROM.

Keyboard Shortcuts

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