今天遇到客户需要实现行列转换的功能。
号 名
001 2
001 3
002 4
002 6
变为
号 名1 名2
001 2 3
002 4 6
select *from (select b.no,b.mp_no a lead(a.mp_no)
over(partition by a.id order by a.mp_no desc) b
from table a, table b
where......)
where b is not null
[@more@]来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24214296/viewspace-1036679/ ,如需转载,请注明出处,否则将追究法律责任。