如何在oracle中将值列表转换为逗号分隔值

时间:2015-07-16 11:34:34

标签: sql oracle comma

id date
1  30/12/1987
1  20/01/1988
1  15/02/2000
2  02/02/2014
2  15/02/2014
3  10/10/1988

结果应该是

1 30/12/1987,20/01/1988,15/02/2000
2 02/02/2014,15/02/2014
3 10/10/1988

2 个答案:

答案 0 :(得分:2)

喜欢这个

SELECT 
    id,
    LISTAGG(date, ', ') WITHIN GROUP (ORDER BY id) "Dates"
FROM mytable
GROUP BY id

答案 1 :(得分:0)

简单方法:

SELECT id, wm_concat(Date) as Dates
FROM   tablename
GROUP BY id;