I have two tables, tblAcct first has 3 fields: AccountID, StartDate, EndDate
The second, tblData, has the 2 fields: DDate, iValue
I need a query that will sum iValue over the Start and End dates in each record in tblAccount, For example:
In the query I need, the first record, Sum_iValue = 259 would be all the iValue numbers from 1/15/10 to 2/14/10 added together. And so on for each record in tblAccount
The second, tblData, has the 2 fields: DDate, iValue
I need a query that will sum iValue over the Start and End dates in each record in tblAccount, For example:
Code:
tblAcct:
AccountID StartDate EndDate
CDD001 01/15/10 02/14/10
CDD002 01/17/10 02/15/10
CDD003 02/05/10 03/03/10
CDD001 02/15/10 03/14/10
CDD002 02/16/10 03/15/10
CDD003 03/04/10 04/03/10
tblData:
DDate iValue
01/15/10 10
01/16/10 9
01/17/10 11
01/18/10 5
01/19/10 7
etc
Code:
Output:
AccountID StartDate EndDate Sum_iValue
CDD001 01/15/10 02/14/10 259
CDD002 01/17/10 02/15/10 275
CDD003 02/05/10 03/03/10 289
CDD001 02/15/10 03/14/10 260
CDD002 02/16/10 03/15/10 241
CDD003 03/04/10 04/03/10 301