I'm trying to do a distinct operation on OHLC data where I have multiple dates per symbol
I can do the operation itself just fine, it only returns date, and symbol
select distinct timestamp, symbol from mv_qs_facts group by mv_qs_facts.symbol, mv_qs_facts.timestamp;
but I'd like it to return all columns (additional: close, open, high, low, volume) as well.
My goal is to return the last distinct (timestamp, symbol)
an idea I had.
select distinct on (timestamp, symbol), close, open, high, low from mv_qs_facts group by mv_qs_facts.symbol, mv_qs_facts.timestamp;
I see it's not as easy as this statement.
I've read I might be able to solve it with a subquery, a temporary table, or a join (all which don't use distinct).