I’ve been trying for a while now to figure this out but my lack of more advanced SQL skills are holding me back.
Executions(TradeDate, Symbol, Side, Price, Under, Account)
TEMP DATA:
2012-06-20, AAPL 120716C00600000, BUY, 3.25, AAPL, XYZ123
2012-06-20, AAPL 120716C00600000, SELL, 3.30, AAPL, XYZ123
2012-06-20, AAPL 120716C00600000, BUY, 3.25, AAPL, XYZ123
2012-06-20, AAPL 120716C00600000, SELL, 3.30, AAPL, XYZ123
2012-06-20, GRPN 120716C00027000, BUY, 2.25, GRPN, XYZ123
2012-06-20, GRPN 120716C00027000, SELL, 2.30, GRPN, XYZ123
2012-06-20, GRPN 120716C00027000, SELL, 2.30, GRPN, XYZ123
2012-06-20, GRPN 120716C00027000, BUY, 2.25, GRPN, XYZ123
-UNDER----Side(Buy)----Side(Sell)
AAPL 6.50 6.60
GRPN 4.50 4.60
As you can see I’m trying to get the SUM of the Price for each Side and then grouped by the Under.
Use
GROUP BYto group byUndercolumn andCASEassociated withSUMto get the needed results: