I have the following query
SELECT P.ID, MAX(ENTERDATE) as ENTERDATE, MAX(B.CostID) as CostID
FROM Protocol P JOIN BANK B ON P.ID= B.ID
group by P.ID
I need to find out what the Maximum enterdate was along with the corresponding CostID but I do not want to use MAX(B.CostID) but I am forced
to do so as I have a group by P.ID and all other fields need to have some kind of aggregate. How do I say group by P.ID and show me the max(enterdate) but give me the corresponding CostID for that Enterdate?
OR something like