select masterid as 单据号, timecount as 时长 from tbovertimedetail
union 
select str(@@rowcount) ,sum(timecount) from tbovertimedetail
单据号          时长                                       
------------ ---------------------------------------- 
         6   14.0
Over01000001 1.5
Over01000002 1.5
Over01000003 3.0
Over01000004 4.0
Over01000005 4.0(所影响的行数为 6 行)
我怎么把那个汇总的行放在最下面?谢谢各位!
如果用ORDERY BY,单据号又到过来了!

解决方案 »

  1.   


    select masterid as 单据号, timecount as 时长,0 as px from tbovertimedetail
    union 
    select str(@@rowcount) ,sum(timecount),1 from tbovertimedetail
    order by px
      

  2.   

    select masterid as 单据号, timecount as 时长,0 as px from tbovertimedetail
    union 
    select str(@@rowcount) ,sum(timecount),1 from tbovertimedetail
    order by px,timecount
      

  3.   

    子查询下不就可以了么?select *
    from(
    select masterid as 单据号, timecount as 时长,0 as px from tbovertimedetail
    union 
    select str(@@rowcount) ,sum(timecount),1 from tbovertimedetail
    )t
    order by px
      

  4.   

    select 单据号,时长
    from(
    select masterid as 单据号, timecount as 时长,0 as px from tbovertimedetail
    union  
    select str(@@rowcount) ,sum(timecount),1 from tbovertimedetail
    )t
    order by px