What will be the output of the following query if the table dept has duplicate…

2023

What will be the output of the following query if the table dept has duplicate department names?


SELECT DISTINCT dept_name
FROM dept
ORDER BY dept_name DESC NULLS FIRST;

  1. A.

    All department names with duplicates removed, but order is random

  2. B.

    All unique department names sorted descending, NULLS first

  3. C.

    Same as GROUP BY dept_name

  4. D.

    All department names sorted ascending, NULLS at bottom

Attempted by 169 students.

Show answer & explanation

Correct answer: B

The correct answer is Option B: All unique department names sorted descending, NULLS first. The DISTINCT keyword eliminates duplicate rows from the output. The ORDER BY dept_name DESC NULLS FIRST clause explicitly sorts these unique department names in descending alphabetical order while positioning any NULL values at the very top of the result set.

Explore the full course: Btsc Lab Assistant