数据库多行合并为一列

SELECT
	t.xm, t.sfzh, ARRAY_JOIN(ARRAY_AGG(DISTINCT t.rylx), ',') rylx -- presto
	t.xm, t.sfzh, GROUP_CONCAT(t.rylx, ',') rylx -- mysql
	t.xm, t.sfzh, CONCAT_WS(',', COLLECT_SET(t.rylx)) rylx -- hive
	t.xm, t.sfzh, LISTAGG(t.rylx, ',') WITHIN GROUP (ORDER BY t.rylx) AS rylx -- oracle
FROM
	(SELECT xm, sfzh, rylx FROM table1) t
GROUP BY
	t.xm, t.sfzh

你可能感兴趣的:(hive,数据库,hive,database,oracle,presto)