Hi Guys,
I'm having an issue with my sum() function on my queries.
My DB has 3 tables
1. plans
2. handset
3. matrix
plans;
- planNum
- planCode
- planName
- planLength
- simRebate
- commission
handset;
- handset
- RRP
matrix;
- planNum
- handset
- subsidy
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.
Thanks