Hi Folks
I have a table in this format
TradeID ActionID
58096 3664
58096 3665
58097 3685
58097 3687
…..
I want to select all the rows but only the rows that represent the highest ActionIDs for each TradeID
For some reason this query is not giving me the correct results
SELECT cct.TradeID,cct .ActionID
FROM comSR_dev.dbo.t est_StagingCort exCommisionTurn over cct
WHERE ActionID = (SELECT MAX(ActionID)
FROM comSR_dev.dbo.t est_StagingCort exCommisionTurn over cct1
WHERE cct.TradeID = cct1.TradeID)
Is there something logically wrong or just my bad sql
I have a table in this format
TradeID ActionID
58096 3664
58096 3665
58097 3685
58097 3687
…..
I want to select all the rows but only the rows that represent the highest ActionIDs for each TradeID
For some reason this query is not giving me the correct results
SELECT cct.TradeID,cct .ActionID
FROM comSR_dev.dbo.t est_StagingCort exCommisionTurn over cct
WHERE ActionID = (SELECT MAX(ActionID)
FROM comSR_dev.dbo.t est_StagingCort exCommisionTurn over cct1
WHERE cct.TradeID = cct1.TradeID)
Is there something logically wrong or just my bad sql
Comment