fboehlandt
Registered User.
- Local time
- Today, 20:31
- Joined
- Sep 5, 2008
- Messages
- 90
Hello everyone,
I have the following normalized table containing the return observations for different dates and various investment funds. The table looks as follows:
[Fund1] [Code1] [Date1] [Return1]
[Fund1] [Code1] [Date2] [Return2]
[Fund1] [Code1] [Date3] [Return3]
...
[Fund1] [Code1] [DateN1] [ReturnN1]
[Fund2] [Code2] [Date1] [Return1]
[Fund2] [Code2] [Date2] [Return2]
[Fund2] [Code2] [Date3] [Return3]
...
[Fund2] [Code2] [DateN2] [ReturnN2]
...
[FundM] [CodeM] [Date1] [Return1]
[FundM] [CodeM] [Date2] [Return2]
[FundM] [CodeM] [Date3] [Return3]
...
[FundM] [CodeM] [DateNM] [ReturnNM]
where M is the total number of funds and Nk denotes the number of observations per fund, [Fund] is the fund's name and
I hope anyone's got a more efficient query to do this. Any help is greatly appreciated...
I have the following normalized table containing the return observations for different dates and various investment funds. The table looks as follows:
[Fund1] [Code1] [Date1] [Return1]
[Fund1] [Code1] [Date2] [Return2]
[Fund1] [Code1] [Date3] [Return3]
...
[Fund1] [Code1] [DateN1] [ReturnN1]
[Fund2] [Code2] [Date1] [Return1]
[Fund2] [Code2] [Date2] [Return2]
[Fund2] [Code2] [Date3] [Return3]
...
[Fund2] [Code2] [DateN2] [ReturnN2]
...
[FundM] [CodeM] [Date1] [Return1]
[FundM] [CodeM] [Date2] [Return2]
[FundM] [CodeM] [Date3] [Return3]
...
[FundM] [CodeM] [DateNM] [ReturnNM]
where M is the total number of funds and Nk denotes the number of observations per fund, [Fund] is the fund's name and
Code:
some arbitrary serial number unique to each fund. Note that not all funds have the same number of observations (i.e. different reporting start and end dates).
I would like to run a query so as to extract funds with a continuous performance track record between a specified start and end date. I came up with the following query that works. However, it is very slow and not very elegant. In addition, it assumes that if a fund has a record for the start date and the end date, then the record must have a continuous track record between those dates (which, luckily, is true):
[CODE]SELECT Performance.*
FROM Performance
WHERE Performance.Code IN
(SELECT Performance.Code
FROM Performance
WHERE Performance.Code IN
(SELECT Performance.Code
FROM Performance
WHERE Performance.MM_DD_YYYY=#startdate#)
AND Performance.MM_DD_YYYY=#enddate#)
AND Performance.MM_DD_YYYY BETWEEN #startdate# AND #enddate#;
I hope anyone's got a more efficient query to do this. Any help is greatly appreciated...