SQL语句实现行转列
wmsys.wm_concat是oracle 10g推出的,用来连接字符串,LISTAGG是oracle 11g推出的,它的作用和wmsys.wm_concat是一样的。
select listagg(p.id_card,’,’) within group(order by p.PERSON_ID) PERSON_IDCARDS from cbms_lib_person p where p.person_id in (136565,158756,158762,158761,149569,153512,89376,70196)
效果如下:
![](https://img2018.cnblogs.com/blog/1311553/201811/1311553-20181108101940411-874714864.png)