I am collecting quote data and chose opt_ticker and quoteTimeStamp as the primary key so that I can store unique quotes over time. I now want to create a view where I can see the latest quote for each opt_ticker (data base has other opt_tickers with unique quotes as well). Basically want to see the latest quote for each stock/option.
In the example above, I want to get that last row as it is the latest timestamp for that particular contract.
I thought this query would do the trick but mysql complains that I need to do a group by.
select symbol,opt_ticker,ask,bid,exp,strike,type,max(quoteTimeStamp)
from optionquotes
group by opt_ticker
21:36:42 select symbol,opt_ticker,ask,bid,exp,strike,type,max(quoteTimeStamp) from optionquotes group by opt_ticker,symbol LIMIT 0, 1000 Error Code: 1055. Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'od2.optionquotes.ask' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by 0.000 sec
Here my server info if it helps
Server
Product: (Ubuntu)
Version: 5.7.30-0ubuntu0.16.04.1
Connector
Version: C++ 8.0.20
This sounds so easy but I am having the toughest time figuring this out, thank you in advance.