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,单据号又到过来了!
select masterid as 单据号, timecount as 时长,0 as px from tbovertimedetail
union
select str(@@rowcount) ,sum(timecount),1 from tbovertimedetail
order by px
union
select str(@@rowcount) ,sum(timecount),1 from tbovertimedetail
order by px,timecount
from(
select masterid as 单据号, timecount as 时长,0 as px from tbovertimedetail
union
select str(@@rowcount) ,sum(timecount),1 from tbovertimedetail
)t
order by px
from(
select masterid as 单据号, timecount as 时长,0 as px from tbovertimedetail
union
select str(@@rowcount) ,sum(timecount),1 from tbovertimedetail
)t
order by px