Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
分组方式中的Oracle字符串聚合_Oracle - Fatal编程技术网

分组方式中的Oracle字符串聚合

分组方式中的Oracle字符串聚合,oracle,Oracle,我已经形成了一个大型查询,它获取了一个具有以下数据条件的大型数据集 Column1 Column2 M1 OTH M1 HHM M1 RES M2 HHM M2 RES M3 OTH M3 RES 我需要将其形成为: M1 OTH,HHM,RES M2 HHM,RES M3 OTH,RES 非常感谢您的帮助。您

我已经形成了一个大型查询,它获取了一个具有以下数据条件的大型数据集

Column1 Column2  
M1        OTH  
M1        HHM  
M1        RES  
M2        HHM  
M2        RES  
M3        OTH  
M3        RES  
我需要将其形成为:

M1        OTH,HHM,RES  
M2        HHM,RES  
M3        OTH,RES  

非常感谢您的帮助。

您可以使用中介绍的可用字符串聚合技术之一

例如:

SELECT COLUMN1, LISTAGG(COLUMN2, ',') WITHIN GROUP (ORDER BY COLUMN1) AS COLUMN2s
FROM TABLE
GROUP BY COLUMN1;