SQLServer2008 行转列2

with a as (
select numb,name,row_number() over( partition by numb order by name desc) rowid 
from fenzu
)
select 
	max(case when rowid=2 then name end) name2,
	max(case when rowid=1 then name end) name, 
	a.numb
from a
group by a.numb

 

posted @ 2015-02-28 14:12  emmy  阅读(337)  评论(0编辑  收藏  举报