I'm having an issue with my sum() function on my queries.
My DB has 3 tables
The query that I'm trying to run is as follows;
SELECT planCode, handset, planName, RRP, simRebate, commission, subsidy, SUM( subsidy + simRebate + commission - RRP ) AS total FROM plans RIGHT JOIN ( vhandsetmatrix LEFT JOIN vodahandsets USING ( handset ) ) USING ( planNum )
However, I would like to run the above SUM() on each row rather than on the whole table.
Help would be much appreciated.