oracle的 LISTAGG() WITHIN GROUP () 行转列函数的使用
test_id 字段信息是重复数据
RE_ID 不同
按照 test_id 分组,RE_ID 值用逗号隔开。
select test_id, LISTAGG(RE_ID, ‘,’) within
group(order by test_id) as REIDS
from ba_detail
group by test_id;
例如:
select test_id, RE_ID from ba_detail;
结果如下:
test_id
RE_ID
1
张三
1
李四
2
王五
2
原创
2020-10-26 17:23:03 ·
303 阅读 ·
0 评论