K
kohai
Hi,
I have a table that has 3 fields, dDate, Return, MCap
I am trying to get a query that will give me the average of Return for the
Top 10 companies with the largest MCap for each day.
I have the below working, but can only do so for an individual day. I can't
get it to work for all the days.
SELECT [DailyData].dDate, Avg([DailyData].Return) AS AvgOfReturn
FROM DailyData
WHERE ((([shares]*[price]) In (SELECT TOP 10 ([shares]*[price]) AS mcap FROM
DailyData WHERE ((([DailyData].dDate)=#11/15/2005#)) ORDER BY
([shares]*[price]) DESC) AND (([DailyData].dDate)=#11/15/2005#))
GROUP BY [DailyData].dDate;
If I expand the date range, it takes the the top 10 companies over all of
the dates and returns the avg. I want it for each day, and the top 10 can
and will change each day.
Thank you.
kohai
I have a table that has 3 fields, dDate, Return, MCap
I am trying to get a query that will give me the average of Return for the
Top 10 companies with the largest MCap for each day.
I have the below working, but can only do so for an individual day. I can't
get it to work for all the days.
SELECT [DailyData].dDate, Avg([DailyData].Return) AS AvgOfReturn
FROM DailyData
WHERE ((([shares]*[price]) In (SELECT TOP 10 ([shares]*[price]) AS mcap FROM
DailyData WHERE ((([DailyData].dDate)=#11/15/2005#)) ORDER BY
([shares]*[price]) DESC) AND (([DailyData].dDate)=#11/15/2005#))
GROUP BY [DailyData].dDate;
If I expand the date range, it takes the the top 10 companies over all of
the dates and returns the avg. I want it for each day, and the top 10 can
and will change each day.
Thank you.
kohai