Re: Display Query Result
Thank you Peter for your replay to my query!
I am just back, was away for the last 2 weeks and have not got a chance to look at the post.
I have run the query you syggested above and got this error message;
13:38:04 select e.spender, sum(e.cost) as totalexpenses, r.total, p.mempayment, r.total + p.mempayment as count, r.total + p.mempaymeny - e.totalexpenses as remaining from expenses e join (select FundRaiser, sum(totalraised) as total from raisedfund group by FundRaiser) r on e.spender=r.raiser join (select payer, sum(howmuch) as mempayment from payment group by payer) p on e.spender=p.payer where e.spender=officeID group by e.spender
Error Code: 1054. Unknown column 'p.mempaymeny' in 'field list' 0.078 sec
This because there is no such column in Payment table! and it is like this (PayNo, Payer, Paydate, HowMuch) Payer is FK and linked to a Member table which is not used in this query. and there is no link between this table and the other 2 Expenses and RaisedFund!.
That's why I want to go for SP and declare mempayment varible to be used with the other for the computation.
The whole idea is to
1- Sum the howMuch column in Payment table.
2- Sum the total raised in Raisedfund table.
3- add them togather as totalincome.
4- Sum the cost column in Expenses.
5- Take off stage 4 from 3 to get the NetIncome.
Subject
Written By
Posted
Re: Display Query Result
May 31, 2015 06:56AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.