HANA、Oracle 多行数据转为一行

HANA

WITH t AS (
SELECT 1 num FROM dummy
UNION 
SELECT 2 num FROM dummy
UNION 
SELECT 3 num FROM dummy
)
SELECT STRING_AGG(num,',' ORDER BY num) FROM t

Oracle

WITH t AS (
SELECT 1 num FROM DUAL
UNION 
SELECT 2 num FROM DUAL
UNION 
SELECT 3 num FROM DUAL
)
SELECT WM_CONCAT(num) FROM t

SQL SERVER

WITH t AS (
SELECT 1 num
UNION 
SELECT 2 num
UNION 
SELECT 3 num 
)
select stuff((SELECT ','+CAST(num as varchar) FROM t for xml path('')),1,1,'')

MySQL

WITH t AS (
SELECT '1' num
UNION 
SELECT '2' num
UNION 
SELECT '3' num 
)
select group_concat(num) from t

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