create table tb1
(
wn varchar(30),
no int,
qty int
)insert into tb1
select 'w01',1,5 union all
select 'w01',1,3 union all
select 'w01',1,4 union all
select 'w02',1,5 union all
select 'w02',1,1 union all
select 'w03',1,5 union all
select 'w03',1,6
goselect identity(int,1,1) as id ,* into #temp from tb1 order by wnselect wn,(select count(*) from #temp where wn=t1.wn and id <=t1.id ) as no ,qty from #temp t1drop table #temp,tb1
(
wn varchar(30),
no int,
qty int
)insert into tb1
select 'w01',1,5 union all
select 'w01',1,3 union all
select 'w01',1,4 union all
select 'w02',1,5 union all
select 'w02',1,1 union all
select 'w03',1,5 union all
select 'w03',1,6
goselect identity(int,1,1) as id ,* into #temp from tb1 order by wnselect wn,(select count(*) from #temp where wn=t1.wn and id <=t1.id ) as no ,qty from #temp t1drop table #temp,tb1
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货