HiI am converting some access to SQL at work and I am having a problem with a query that uses the access FIRST functionMy query looks like this in accessSELECT TBL1.ID , FIRST(TBL1.Code) AS FirstCodeFROM TBL1WHERE TBL1.Marker = 'X' AND Left(ID,1) IN('A','B','C','D','E')GROUP BY ID
I have tried to convert it using a slightly different method. So instead of picking the first value of the Code field that appears in the select, (which is what access would do and SQL can’t do as far as I’m aware). I first select the ID and code with the highest value associated with them. I hope this makes sense. The below script is what I did. I would’ve thought they would produce the same number of records but they don’t. Would anyone know a better method for the producing the acccess query result in SQL? Kind regardsSELECT ID , Code FirstCodeFROM ( SELECT ID , Code , MAX(Value) MaxValue FROM TBL1 WHERE TBL1.Marker = 'X' AND LEFT(ID,1) IN('A','B','C','D','E') GROUP BY ID , Code ) T1