日期:2014-05-17 浏览次数:20469 次
declare @tab table
(
id int,
[type] int,
[values] nvarchar(50)
)
insert into @tab(id,[type],[values])
select 0,0,'红茶' union all
select 1,0,'绿茶' union all
select 2,0,'奶茶' union all
select 3,1,'a茶' union all
select 4,1,'b茶' union all
select 5,1,'c茶'
select case when pg=1 then [type] else null end as [type],[values] from
(
select row_number() over(partition by [type] order by id asc) as pg,* from @tab
) t