A
Accessor
Hello all. I'm struggling a bit with a query I'm trying to write. It's based
on two tables with a one to many relationship. The "one" side is a master
list of stock symbols. The many table is daily price and trading volume for
each stock. I'm trying to add several fields, starting with the symbol. I
then want to have fields get data from different dates (latest data point,
the day before, etc). I've pasted below what I've got so far. This query runs
but the last field (the subquery) is blank when executed. Any ideas? Maybe
the join? Please help!! Thanks in advance...
Kevin
SELECT DISTINCT tblSymbolsMain.Symbol, tblSymbolsMain.Company,
tblStocksPricingVol.PricingVolWebQueryDate AS LatestDate,
CDate(Workday([LatestDate],-1)) AS DatePriorToLatest,
(SELECT M2.LowPrice FROM tblStocksPricingVol AS M2 WHERE M2.Symbol = Symbol
AND M2.PricingVolWebQueryDate = DatePriorToLatest) AS DatePriorToLatestLowPr
FROM tblSymbolsMain INNER JOIN tblStocksPricingVol ON tblSymbolsMain.Symbol
= tblStocksPricingVol.Symbol
WHERE
(((tblStocksPricingVol.PricingVolWebQueryDate)=DMax("PricingVolWebQueryDate","tblStocksPricingVol","Symbol='" & [tblStocksPricingVol].[Symbol] & "'")));
on two tables with a one to many relationship. The "one" side is a master
list of stock symbols. The many table is daily price and trading volume for
each stock. I'm trying to add several fields, starting with the symbol. I
then want to have fields get data from different dates (latest data point,
the day before, etc). I've pasted below what I've got so far. This query runs
but the last field (the subquery) is blank when executed. Any ideas? Maybe
the join? Please help!! Thanks in advance...
Kevin
SELECT DISTINCT tblSymbolsMain.Symbol, tblSymbolsMain.Company,
tblStocksPricingVol.PricingVolWebQueryDate AS LatestDate,
CDate(Workday([LatestDate],-1)) AS DatePriorToLatest,
(SELECT M2.LowPrice FROM tblStocksPricingVol AS M2 WHERE M2.Symbol = Symbol
AND M2.PricingVolWebQueryDate = DatePriorToLatest) AS DatePriorToLatestLowPr
FROM tblSymbolsMain INNER JOIN tblStocksPricingVol ON tblSymbolsMain.Symbol
= tblStocksPricingVol.Symbol
WHERE
(((tblStocksPricingVol.PricingVolWebQueryDate)=DMax("PricingVolWebQueryDate","tblStocksPricingVol","Symbol='" & [tblStocksPricingVol].[Symbol] & "'")));