How to display column values from multiple rows in to comma separated values in a single row in Oracle ?

Use the following SQL query in Oracle to display column values from multiple rows in to comma separated values in a single row.

SELECT dept_no, LISTAGG(emp_name, ',') WITHIN GROUP (ORDER BY emp_name) AS employees
FROM   employee
GROUP BY dept_no;

Search