MySQL Forums
Forum List  »  Newbie

Re: calculating a column´s value from two registries
Posted by: Ramalingam Chelliah
Date: September 02, 2004 10:02PM

Hi ,
You have not given table description or which tables you joined ....

But here is a hint ....

To the previous query JOIN (Prefer LEFT OUTER JOIN )
more (same) table(s)
( for getting Year ,Month,concept,Payment) but
ON condition that Month is same ,concept is same, Year =Year+1

Then subtract the values of Payment .....

Hope this helps you...

Regards,
Ram.

P.S:

Suppose if I have table 'sample' with fields Year,Month,Value
Then

SELECT X.Year,X.Month,X.Value,(X.Value-Y.Value) as 'Annual Profit'
FROM
sample as X
LEFT OUTER JOIN
sample as Y
ON X.Month=Y.Month AND X.Year=(Y.Year+1) ;





We Learn the Most When we have to Invent

Options: ReplyQuote


Subject
Written By
Posted
Re: calculating a column´s value from two registries
September 02, 2004 10:02PM


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.