You are on the right lines - what you want isn't a Distinct or any kind of Group By, and "a kind of max for each FieldFK." is pretty much it.
The way to do that is to use a sub-query (using the same table) based on FieldFK, which you can do like this:
By giving the table an alias in the main query, you can refer to the values from it in the sub-query, thus causing the sub-query to run for each row of the main query (and be linked to it).Code:SELECT idReg, FieldFK, InternalNumber, Name, Qt FROM tableName as t1 WHERE idReg = (SELECT Max(idReg) FROM tableName WHERE FieldFK = t1.FieldFK)




Reply With Quote