select t1.*, t2.ofLogin as ofName, t3.fiName from
( --移动
select ormOid as offId, ormType as funid,cast(sum(ormPayAmount) AS decimal(18,2)) as amountsum from ordermobile
where ormState in (2,6) and ormExecTime >= @st and ormExecTime<=@et group by ormOid, ormType
union --联通
select oruOid as offId, oruType as funid,cast(sum(oruPayAmount) AS decimal(18,2)) as amountsum from orderunicom
where oruState in (2,6) and oruExecTime >= @st and oruExecTime<=@et group by oruOid, oruType
union --电信
select ortOid as offId, ortType as funid,cast(sum(ortPayAmount) AS decimal(18,2)) as amountsum from ordertelecom
where ortState in (2,6) and ortExecTime >= @st and ortExecTime<=@et group by ortOid, ortType
) as t1,
officeInfo as t2, functionInfo as t3 where t1.offId = t2.ofId and t1.funid = t3.fiId
order by ofName 这不是你想要的类型吗