select (select count(*) from tablename where a=A.a and b+c<=A.b+A.c) GroupRecNO,* from tablename A

解决方案 »

  1.   

    select identity(int,1,1) as id,* into #temp from table
    select (select count(*) from tabel where a=AA.a and id<=AA.id),aa.* from table AA
      

  2.   

    select identity(int,1,1) as id, * into #temp from table
    select (select count(*) from #temp where a=AA.a and id<=AA.id) as GroupRecNO ,a,b,c from #temp AA
      

  3.   

    select identity(int,1,1) as id,* into #temp from table
    select (select count(*) from #temp where a=AA.a and id<=AA.id),aa.* from #temp AAdrop table #temp