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



