select id=(select count(1) from 表名 a where a.reser=b.reser and a.price<=b.price),* from 表名 b

解决方案 »

  1.   

    create table tabAAA(reser int ,price int )-- select * from tabaaa
    -- select * from tabBBBselect identity(int,1,1) as  id ,* into tabBBB from tabaaaselect id=(select count(reser) from tabbbb where a.reser=tabbbb.reser and tabbbb.id<=a.id) ,*
    from tabbbb a好象没有一条语句可以做到吧
      

  2.   

    这里换下 select identity(int,1,1) as  id ,* into tabBBB from tabaaa order by reserselect id=(select count(reser) from tabbbb where a.reser=tabbbb.reser and tabbbb.id<=a.id) ,*
    from tabbbb a
    order by a.reser