oracle 函数WMSYS.WM_CONCAT()的用法(让查询结果行转列)
test表结构和数据为:
id starttime
1 2010/11/12
1 2010/12/12
2 2011/3/2
sql语句:
select id,substr(aa,0,10) starttime1,substr(aa,21,10) starttime2,substr(aa,31,10) starttime3
from (
select t.id,WMSYS.WM_CONCAT(t.starttime) aa from
test t
group by t.id)
显示结果:
id starttime1 starttime2 starttime3
1 2010/11/12 2010/12/12 null
2 2011/3/2 nulll null