记忆力不大好,随手贴一个帖子记录一下
假设有如下的一张表table1,如果想把carlie按照用户名汇总输出,那么SQL如下
select Name,temp.car
from table1, (select name, WMSYS.WM_CONCAT(to_char(car)) car from table1 group by name) temp
where name = temp.name;
输出效果如下:
amy | x1,x5,x6
lulu | x1,x3
table1
ID | Name | car | |
1 | amy | amy@abc.com.cn | x1 |
2 | amy | amy@abc.com.cn | x5 |
3 | amy | amy@abc.com.cn | x6 |
4 | lulu | lulu@abc.com.cn | x1 |
5 | lulu | lulu@abc.com.cn | x3 |