借邹建的 select *,id=( select count(distinct operation) from 表 where F1=a.F1 and F2<=a.F2) from 表 a order by F1,F2--2. select *,id=0 into #t from 表 order by F1,F2 declare @a varchar(10),@i int update #t set @i=case @a when F1 then @i+1 else 1 end ,id=@i,@a=F1 select * from #t
select *,id=(
select count(distinct operation)
from 表
where F1=a.F1 and F2<=a.F2)
from 表 a
order by F1,F2--2.
select *,id=0 into #t from 表 order by F1,F2
declare @a varchar(10),@i int
update #t set @i=case @a when F1 then @i+1 else 1 end
,id=@i,@a=F1
select * from #t