我有一张表,我保存有关财务回报的信息。这些专栏包括收据,维修,service_amount,轮胎,燃料,薪金许可等。如何获取累计总计mysql
我想获得的累计净回笼,如:
Date Receipts repairs service amount Total costs net Return
2012-01-10 0.00 120,000.00 0.00 120,000.00 120,000.00
2012-01-12 60,000.00 0.00 0.00 60,000.00 60,000.00
我目前使用此查询:
SELECT
a.consignment_date, a.receipts, a.service_amount, a.repairs, a.tyres,
a.salaries_allowances, a.clearing_fee, a.others,
a.service_amount + a.repairs + a.tyres + a.salaries_allowances + a.clearing_fee + a.others as total_costs,
(b.receipts -(a.service_amount + a.repairs + a.tyres + a.salaries_allowances + a.clearing_fee + a.others)) as netreturn
FROM
vw_local_freight a CROSS JOIN vw_local_freight b
WHERE
a.consignment_date >= b.consignment_date AND a.vehicle_no='123X'
GROUP BY a.consignment_date
你的问题是模糊的,它不详细,他们是如何计算的,将承担所有费用被算作“修理”并且是成本,而收据是信用? – 2012-02-21 09:15:19