I've used the following stackoverflow post to try and get a record with the latest date: Select info from table where row has max date
I wrote the following query:
SELECT AR_SQ.SYMBOL, AR_SQ.NAME, AR_SQ.LAST, FF_PS.SECTOR, FF_PS.SECTOR_TAGS, HP.LAST_10_DAYS, HP.YTD_PERF
FROM AR_STOCK_QUOTE AR_SQ
LEFT JOIN (
SELECT HP.SYMBOL, max(TRADE_DATE) as MaxDate
FROM FF_HISTORICAL_STOCK_PRICE HP
GROUP BY HP.SYMBOL
)
HP on HP.SYMBOL = AR_SQ.SYMBOL
JOIN FF_PRIMARY_STOCK_TABLE FF_PS on FF_PS.SYMBOL = AR_SQ.SYMBOL
When I do this though, I get a error message saying the following:
Error Code: 1054. Unknown column 'HP.LAST_10_DAYS' in 'field list'
Why would this be the case since HP is defined and it's a field in that table?