The LISTAGG analytic function was introduced in Oracle 11g Release 2.
the function is used to do string aggregations.
suppose I have data in employee table like this.
the function is used to do string aggregations.
suppose I have data in employee table like this.
and we wanted display department_id and all the related employee first_name in one row , like below.
then we can use LISTAGG function to aggregate the strings.
here is the query.
select department_id,LISTAGG(first_name||',') within group (order by first_name) as Employee from EMPLOYEES
group by DEPARTMENT_ID;
Note: I have used EMPLOYEES table from HR schema in Oracle 12c.