能否写条sql语句,实现一下功能id orderno time 
1   1234   2008-10-10
2   1234   2008-10-11
3   2222   2008-10-10
4   2222   2008-10-11id orderno time         paixu
1   1234   2008-10-10    1
2   1234   2008-10-11    2
3   2222   2008-10-10    1
4   2222   2008-10-11    2orderno是订单号码,time是时间,我想同一种订单按照时间排序,并把顺序号给paixu字段,请问怎么做比较好呢,谢谢大家

解决方案 »

  1.   

    select *,(select count(*) from tt where a.orderno=orderno and a.time<=time) from tt a
      

  2.   

    后面再加上 order by orderno asc, time asc
    排序规则自己定
      

  3.   

    select a.id,a.orderno,a.time,count(*) as paixu
    from yourTable a , yourTable b
    where a.time>=b.time
    group by a.id,a.orderno,a.time.
        [align=center]====  ====
    [/align]
    .
    贴子分数<20:对自已的问题不予重视。
    贴子大量未结:对别人的回答不予尊重。
    .