How to do this in mySQL?
Posted: Thu Jan 16, 2003 4:36 am
Hallo,
I have this problem:
One table contains list of debts, identified by dbtID and other fields.
Other table contains list of cashflows, with field dbtID identifiying the
corresponding debt, cfDate identifying the date of cashflow, and cfAmount
describing the amount (could be both positive and negative).
Now, I need to create a SQL statement to get list of debts, with the
following columns:
column 1: Debt ID (dbtID);
column 2: Original balance (i.e. the earliest corresponding balance)
As far I can see, I don't have straightfowrward way to create a list of
cashflows, grouped by dbtID, and taking the cfAmount value from the record
where cfDate is the smallest.
I am looking for an ANSI-compliant SQL string, so that it would work on
other database formats, too.
Thanks for your help!
-- Brother
I have this problem:
One table contains list of debts, identified by dbtID and other fields.
Other table contains list of cashflows, with field dbtID identifiying the
corresponding debt, cfDate identifying the date of cashflow, and cfAmount
describing the amount (could be both positive and negative).
Now, I need to create a SQL statement to get list of debts, with the
following columns:
column 1: Debt ID (dbtID);
column 2: Original balance (i.e. the earliest corresponding balance)
As far I can see, I don't have straightfowrward way to create a list of
cashflows, grouped by dbtID, and taking the cfAmount value from the record
where cfDate is the smallest.
I am looking for an ANSI-compliant SQL string, so that it would work on
other database formats, too.
Thanks for your help!
-- Brother