Exam 1z0-071 All QuestionsBrowse all questions from this exam
Question 119

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

    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
ArslanAltafOption: A

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

ArslanAltafOption: A

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

amizhOption: A

tried it in sql developer