I'm learning oracle sql.
I'm just trying to display all the employees first name from 'Employee' table in single line with comma separation.
ex: john,alex,rosy
I'm using SQL*Plus for running the query.
I'm learning oracle sql.
I'm just trying to display all the employees first name from 'Employee' table in single line with comma separation.
ex: john,alex,rosy
I'm using SQL*Plus for running the query.
You have to use some built in function like:
SYS_CONNECT_BY_PATH , ROW_NUMBER () OVER
SQL>
SQL> create table test(id int, name varchar(10));
Table created
SQL> begin
2 insert into test values(1,'john');
3 insert into test values(2,'alex');
4 insert into test values(3,'rosy');
5 end;
6 /
PL/SQL procedure successfully completed
SQL> select listagg(name ,',') within group(order by id) result from test;
RESULT
--------------------------------------------------------------------------------
john,alex,rosy
SQL> drop table test purge;
Table dropped
SQL>