Getting column values in single row separated by comma in oracle Sql
Suppose you want to convert the single column result coming in multiple rows to a single row separated by comma, following is an example for your clarifications:
SQL> Select emp_name from emp where dept = 'Accounts';
EMP_NAME
----------------
JOHN,
SMITH,
SCOTT,
ADAM
But you want the result in a single row something like this:
JOHN, SMITH, SCOTT, ADAM
You can do this task with the wm_concat function of WMSYS schema/user.
Below is the example:
Select wm_concat(emp_name) from emp;
It will show the result as below:
JOHN, SMITH, SCOTT, ADAM
Limitations
4000 characters