完美的解答了俺的问题! |
再在外面套一层select select 要显示的字段, max(费用总额)-sum(实收金额)-max(优惠金额) as 挂账金额 ,max(费用总额)-max(优惠金额)-max(工时费)-max(进价) 毛利 from (select a.业务编号, a.制单日期, a.车主, a.车牌号码, b.费用总额, b.工时费, b.配件费 材料费, sum(b.优惠金额)优惠金额, sum(b.实收金额) 实收金额, sum(b.进价) 材料成本, --挂账金额=费用总额-优惠金额-实收金额 b.费用总额 - nvl(b.优惠金额, 0) - nvl(b.实收金额, 0) 挂账金额, --毛利=费用总额-优惠金额-工时费-进价 b.费用总额 - nvl(b.优惠金额, 0) - nvl(b.工时费, 0) - nvl(sum(b.进价), 0) 毛利 from S4_前台接车 a, S4_维修结算 b where a.id = b.项目id group by a.业务编号, a.制单日期, a.车牌号码, a.车主, b.费用总额, b.工时费, b.配件费, b.优惠金额, b.实收金额, b.进价) group by 要显示的字段 |
Powered by Discuz! X3.2
© 2001-2013 Comsenz Inc.