Thanks Ajax for your reply,
I have edited my original post to make it a little clearer and also part of the formatting screwed up originally which may have contributed to some confusion.
Looking at a crosstab while that gives me the data I don't know how to tell it to just show select dates (ie. 1 week ago, 1 month ago, 3 months ago and so on without all the other dates inbetween). Also keeping in mind that my dataset currently has over a years work of data (368 dates so far) so crosstab doesn't appear to allow me to place dates across the top unless I can filter just the dates I want somehow and instead I have the StockID across the top. This is probably ideal solution if I can transpose the rows / columns data, set dates for the date paramater across the top to just select dates and provide a heading for each of these columns.
Code:
TRANSFORM Sum(tblHistory.ClosePrice) AS SumOfClosePriceSELECT tblHistory.rDate
FROM tblHistory
GROUP BY tblHistory.rDate
PIVOT tblHistory.StockID;
The starting phase of A select query is as follows but can't get it beyond this without it crashing
Code:
SELECT TOP 1 tblHistory.StockID, Last(tblHistory.ClosePrice) AS CurrentPrice, tblHistory_1.ClosePrice AS 1WkClosePrice, tblHistory_1.rDate AS rDate01wFROM tblHistory LEFT JOIN tblHistory AS tblHistory_1 ON tblHistory.StockID = tblHistory_1.StockID
GROUP BY tblHistory.StockID, tblHistory_1.ClosePrice, tblHistory_1.rDate
HAVING (((tblHistory_1.rDate)<DateAdd("ww","-1",Date())))
ORDER BY tblHistory_1.rDate DESC;
Note I have got this solution for a similar function that is utilising heaps of queries and does work but it isn't clean and makes the queries list I think very messy to have so many queries for a single element of my reports but if thats what I need then I will go down this similar route but just want to confirm that in theory it is the best / only way to go. In this scenario there is basically the StockID, TimePeriodDate (Calculated with DateAdd function) and the corresponding ClosePrice on that day in each query. Then have a master query that merges it all together with the common link being StockID
Code:
SELECT qryStockOverview01Month.StockID, qryStockOverviewNow.CurrentPrice, qryStockOverviewNow.rDateCurrent, qryStockOverview01Month.[1Month], qryStockOverview01Month.rDate01, Round(([CurrentPrice]/[1Month]*100)-100,2) AS Calc1, qryStockOverview03Month.[3Month], qryStockOverview03Month.rDate03, qryStockOverview06Month.[6Month], qryStockOverview06Month.rDate06, qryStockOverview12Month.[12Month], qryStockOverview12Month.rDate12, qryStockOverview18Month.[18Month], qryStockOverview18Month.rDate18, Round(([CurrentPrice]/[3Month]*100)-100,2) AS Calc3, Round(([CurrentPrice]/[6Month]*100)-100,2) AS Calc6, tblStocksList.Ticker, tblStocksList.FundNameFROM ((qryStockOverviewVolatile1Month RIGHT JOIN (qryStockOverviewVolatile3Month RIGHT JOIN (qryStockOverviewVolatile6Month RIGHT JOIN (((((qryStockOverview01Month LEFT JOIN qryStockOverview03Month ON qryStockOverview01Month.StockID = qryStockOverview03Month.StockID) LEFT JOIN qryStockOverview06Month ON qryStockOverview01Month.StockID = qryStockOverview06Month.StockID) LEFT JOIN qryStockOverview12Month ON qryStockOverview01Month.StockID = qryStockOverview12Month.StockID) LEFT JOIN qryStockOverview18Month ON qryStockOverview01Month.StockID = qryStockOverview18Month.StockID) LEFT JOIN qryStockOverviewNow ON qryStockOverview01Month.StockID = qryStockOverviewNow.StockID) ON qryStockOverviewVolatile6Month.StockID = qryStockOverview01Month.StockID) ON qryStockOverviewVolatile3Month.StockID = qryStockOverview01Month.StockID) ON qryStockOverviewVolatile1Month.StockID = qryStockOverview01Month.StockID) LEFT JOIN qry52WeekBar ON qryStockOverview01Month.StockID = qry52WeekBar.StockID) LEFT JOIN tblStocksList ON qryStockOverview01Month.StockID = tblStocksList.StockID
GROUP BY qryStockOverview01Month.StockID, qryStockOverviewNow.CurrentPrice, qryStockOverviewNow.rDateCurrent, qryStockOverview01Month.[1Month], qryStockOverview01Month.rDate01, Round(([CurrentPrice]/[1Month]*100)-100,2), qryStockOverview03Month.[3Month], qryStockOverview03Month.rDate03, qryStockOverview06Month.[6Month], qryStockOverview06Month.rDate06, qryStockOverview12Month.[12Month], qryStockOverview12Month.rDate12, qryStockOverview18Month.[18Month], qryStockOverview18Month.rDate18, Round(([CurrentPrice]/[3Month]*100)-100,2), Round(([CurrentPrice]/[6Month]*100)-100,2), tblStocksList.Ticker, tblStocksList.FundName;