G
Guest
Hello
I have a table NRL_Performance to hold the performance data of various
investments. It has the following structure:
ID
NRL_Date
Return
When a user selects a particular fund ID, I want to generate the data to
draw a graph of the rolling 12 month returns. I have done this in VB by
finding the start and end dates of the fund (DMax and DMin functions) and
then looping through the date range calculating the total return in 12-month
blocks, moving in one month steps. Hope that makes sense.
I'm putting the answer to that into a temporary table in order to generate
the graph in a report. However, although I am very able to do the
calculation, I can't find a way to catch the date at the same time.
When I try and include NRL_Date as one of the fields I'm inserting into my
new temporary table, I get the aggregate function error message.
This is the SQL for my append query -
sqlstment = "INSERT INTO tblGRAPH_ROLLING_ANNUAL_TEMP(Return) " & _
"SELECT (exp(sum(log(NRL_Performance.Return+1)))-1) as Return " & _
" FROM NRL_Performance WHERE NRL_Performance.ID =" & Chr(34) &
ctlID & Chr(34) & _
" AND NRL_Performance.NRL_Date BETWEEN " & "#" & loop_start &
"#" & "AND" & "#" & loop_end & "#"
loop_start and loop_end are date functions that allow me to step through the
dataset in 12 month batches.
Ideally, I would like the first line of the SQL to look like this -
sqlstment = "INSERT INTO tblGRAPH_ROLLING_ANNUAL_TEMP(NRL_Date, Return)
Any suggestions would be appreciated.
Thanks,
Tarryn
I have a table NRL_Performance to hold the performance data of various
investments. It has the following structure:
ID
NRL_Date
Return
When a user selects a particular fund ID, I want to generate the data to
draw a graph of the rolling 12 month returns. I have done this in VB by
finding the start and end dates of the fund (DMax and DMin functions) and
then looping through the date range calculating the total return in 12-month
blocks, moving in one month steps. Hope that makes sense.
I'm putting the answer to that into a temporary table in order to generate
the graph in a report. However, although I am very able to do the
calculation, I can't find a way to catch the date at the same time.
When I try and include NRL_Date as one of the fields I'm inserting into my
new temporary table, I get the aggregate function error message.
This is the SQL for my append query -
sqlstment = "INSERT INTO tblGRAPH_ROLLING_ANNUAL_TEMP(Return) " & _
"SELECT (exp(sum(log(NRL_Performance.Return+1)))-1) as Return " & _
" FROM NRL_Performance WHERE NRL_Performance.ID =" & Chr(34) &
ctlID & Chr(34) & _
" AND NRL_Performance.NRL_Date BETWEEN " & "#" & loop_start &
"#" & "AND" & "#" & loop_end & "#"
loop_start and loop_end are date functions that allow me to step through the
dataset in 12 month batches.
Ideally, I would like the first line of the SQL to look like this -
sqlstment = "INSERT INTO tblGRAPH_ROLLING_ANNUAL_TEMP(NRL_Date, Return)
Any suggestions would be appreciated.
Thanks,
Tarryn