I am currently facing the following issue: I have 1 Table with my Broker Trading Data similar to this:
TickerId Id Ticker Shares OrderType
... ... ... ... ...
01.01.20 ABC 5 ABC 500 Buy
01.01.20 ABC 6 ABC 250 Sell
01.01.20 ABC 7 ABC 250 Sell
... ... ... ... ...
The Goal is to say IF first OrderType (lowest Id where TradeId is the same) was a Buy, it's a LONG Trade ELSE a Short Trade ... output should be like this:
TickerId Position Ticker Volume (=SUM(Shares))
... ... ... ...
01.01.20 ABC Long ABC 1000
... ... ... ...
What am I missing? How can I construct my Query to accomplish this task?
Thanks for looking into this ;)