UNION
- SELECT SUM(ac.sellprice)
+ SELECT SUM(ac.qty * ac.sellprice)
FROM invoice ac
JOIN ar a ON (ac.trans_id = a.id)
JOIN parts p ON (ac.parts_id = p.id)
UNION
- SELECT SUM(ac.sellprice)
+ SELECT SUM(ac.qty * ac.sellprice)
FROM invoice ac
JOIN ap a ON (ac.trans_id = a.id)
JOIN parts p ON (ac.parts_id = p.id)
UNION
- SELECT SUM(ac.sellprice)
+ SELECT SUM(ac.qty * ac.sellprice)
FROM invoice ac
JOIN ar a ON (ac.trans_id = a.id)
JOIN parts p ON (ac.parts_id = p.id)
UNION
- SELECT SUM(ac.sellprice)
+ SELECT SUM(ac.qty * ac.sellprice)
FROM invoice ac
JOIN ap a ON (ac.trans_id = a.id)
JOIN parts p ON (ac.parts_id = p.id)
UNION ALL
SELECT a.id, a.invnumber, c.name, a.transdate,
- a.invoice, ac.sellprice, 'ar' as module
+ a.invoice, ac.qty * ac.sellprice AS sellprice, 'ar' as module
FROM ar a
JOIN invoice ac ON (ac.trans_id = a.id)
JOIN parts p ON (ac.parts_id = p.id)
UNION ALL
SELECT a.id, a.invnumber, v.name, a.transdate,
- a.invoice, ac.sellprice, 'ap' as module
+ a.invoice, ac.qty * ac.sellprice AS sellprice, 'ap' as module
FROM ap a
JOIN invoice ac ON (ac.trans_id = a.id)
JOIN parts p ON (ac.parts_id = p.id)