这个是部分代码,这里能实现 下面的也就一样了!报错b.vehiclefee无效:
select b.vehiclefee
from (select round(sum(a.artifmate),0)|| null 人工费,round(sum(a.repailmate),0)|| null 材料费,
round(sum(a.vehiclefee),0)|| null 费用总和
from Vehiclerepair a where to_char(a.repaildate,'mm')=1) b
———————————————————————————————————————————————
这是完整代码 代码有点复杂!我的目的是用今年的8月份金额,减去上一年的8月份的金额
select round((sum(b.artifmate)-sum(c.artifmate)))|| null 人工费,
round((sum(b.repailmate)-sum(c.repailmate)))|| null 材料费,
round((sum(b.vehiclefee)-sum(c.vehiclefee)))|| null 费用总和
from (select round(sum(a.artifmate),0)|| null,
round(sum(a.repailmate),0)|| null ,
round(sum(a.vehiclefee),0)|| null
from Vehiclerepair a where to_char(a.repaildate,'mm')=1) b,
(select round(sum(t.artifmate),0)|| null,
round(sum(t.repailmate),0)|| null,
round(sum(t.vehiclefee),0)|| null
from Vehiclerepair t where to_char(t.repaildate,'yyyy')=2014 and to_char(t.repaildate,'mm')=1) c