1z0-071 Exam QuestionsBrowse all questions from this exam

1z0-071 Exam - Question 119


Which statement will return a comma-separated list of employee names in alphabetical order for each department in the EMP table?

Show Answer
Correct Answer: A

The correct SQL statement should select the department number and create a comma-separated list of employee names in alphabetical order for each department. This can be achieved using the LISTAGG function with the appropriate ordering within each department group. Therefore, the correct statement is "SELECT deptno, LISTAGG(ename, ',') WITHIN GROUP (ORDER BY ename) AS employee_list FROM emp GROUP BY deptno;" which uses LISTAGG to concatenate employee names in alphabetical order within their respective departments.

Discussion

3 comments
Sign in to comment
amizhOption: A
Feb 18, 2024

tried it in sql developer

ArslanAltafOption: A
Apr 20, 2024

B, C, D will throw error. A is the only correct option

ArslanAltafOption: A
Jun 5, 2024

A Correct select department_id, listagg(last_name, ',') within group (order by last_name) from employees group by department_id;