我有一張表,我保存有關財務回報的信息。這些專欄包括收據,維修,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