QuestionQ120

VerifiedRestricting and Sorting Data

List the employees in DEPARTMENT_ID 30 in one row, sorted by HIRE_DATE.

Review the sample output:

Question Image

Which query produces the required output?

Question Image

Explanation

LISTAGG(last_name, '; ') WITHIN GROUP (ORDER BY hire_date) concatenates the employee last names into one semicolon-separated value in hire-date order. Because no GROUP BY clause is present, the aggregate operates over all filtered Department 30 rows and returns one row; MIN(hire_date) returns the earliest hire date. Oracle requires WITHIN GROUP together with the ordering clause for ordered LISTAGG results.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!