Glory!

I have one Table (Transactions), having a Date Column,
with date stored as YYYY-MM-DD

I have another Table (Holdings), having a Date Column,
with date stored as YYYY-MM-DD

Now i'm joining the two tables, to get data from both
the tables and display on the page. The query i'm
using is something like this :

SELECT * FROM transactions,holdings where
transactions.isinno=holdings.isinno AND
transactions.clientid='$clientid' AND
holdings.clbal!=0 GROUP BY holdings.isinno ORDER BY
shares

This statement works fine, and for any given date,
extracts Data from both the tables and displays in a
particular row format.

I have to also to do some Calculations as i have
Debit, Credit & Opening Balance of a day, and have to
generate the Closing Balance.

Now for this purpose i'm facing a simple problem. The
Data being picked up is of the same date from both the
Tables. However, what is required is that the Data
from the "Holdings" table needs to be picked up from a
Date a day earlier then the Transactions Table Data.

For eg:- If i'm displaying Transactions Table Data of
2002-06-22, then the Holdings Data should be picked up
of date 2002-06-21 !! 

The thing is that i have Debit & Credit in
Transactions Table, and the Closing Balance in
Holdings Table. The Closing Balance of 21st is the
Opening Balance of 22nd. So when i display the
Transactions Table for 22nd, Debit & Credit of 22nd is
Subtracted & Added to the Opening Balance of 21st to
get the Closing Balance. So this is what i have to do.
I need to pick up the Opening Balance from the
Holdings Table of a Date Previous to the Transactions
that i'm displaying. 

How can i do this?

Thanks,
T. Edison Jr.



__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to