select *,no=(select count(*) from tb where a.c=c and e<a.e)+1
from tb a

解决方案 »

  1.   

    select *,no=row_number() over(partition by d order by e)
    from tb
      

  2.   

    select *,=(select count(*) from tb where a.c=c and d<a.d)+1
    from tb a
      

  3.   

    select *,e =(select count(*) from tb where a.c=c and d <a.d)+1 
    from tb a
      

  4.   

    select * , e = (select count(1) from t1 where a = t.a and b = t.b and c = t.c and d < t.d) + 1 from t1
      

  5.   


    select *,e=(select count(*) from tb where a.c=c and d<a.d)+1 from t1 a
      

  6.   


    select *,e=(row_number() over (partition by c order by d )) from t1
      

  7.   

    谢谢大家,明白了.在这里尤其感谢happyflystone,您给我的这个答复也让我同时解决了我昨晚的提问(根据你的示例解决了同类的问题,再次说声谢谢您!)