日期:2014-05-17  浏览次数:20488 次

sql 将2行,并成一行。
原表
table
id   typeid        info         time
1       1             sohu    2013-03-05
2       2             sina      2013-03-05
3       1             sohu     2013-03-06
4        2            sina       2013-03-06

想要的效果:
id   typeid        info         time             newid         newtypeid        newinfo     newtime
1       1             sohu    2013-03-05       3                    1                    sohu        2013-03-06
2       2             sina      2013-03-05       4                    2                     sina        2013-03-06

试了好久还是没弄出来,有人来帮帮忙么?
sql table

------解决方案--------------------
select * from tb a left join tb b on a.typeid=b.typeid and a.id+2=b.id
where (a.id-1)/2%2=0

------解决方案--------------------
select * from tb a join tb b on a.typeid=b.typeid where a.id<b.id