当前位置:网站首页>Example of using listagg in Oracle 11g (splicing the values of a field into a line, separated by commas)

Example of using listagg in Oracle 11g (splicing the values of a field into a line, separated by commas)

2022-06-22 07:57:00 CodeStorys

LISTAGG Use example of

SELECT T1.SN,  
 LISTAGG(T1.ACT_NAME, ',') WITHIN GROUP(ORDER BY T1.END_TIME)   AS ALL_ACT_LIST,
  LISTAGG(T3.ACT_NAME, ',') WITHIN GROUP(ORDER BY T3.END_TIME) AS VALID_ACT_LIST 
 
  from TABLE_NAME T1
  LEFT JOIN (SELECT * FROM TABLE_NAME T3 WHERE T3.STAT = 2 ) t3
  ON t1.sn =  t3.sn 
  and t1.stat = t3.stat
  and t1.act_name = t3.act_name
  and t1.end_time = t3.end_time
  LEFT JOIN TABLE_NAME T2
  ON T1.SN = T2.SN 
  WHERE T2.PROCESSING_STATUS = ' Disposed of '
 group by T1.SN 
 order by all_act_list ,valid_act_list
原网站

版权声明
本文为[CodeStorys]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202220530548340.html