So ... you want the most recent kal_godkand for each InvId, LopNr combination?SELECT InvId, LopNr, kal_datum AS LastKal, kal_godkandFROM dbo.Inventarie_Kalibrering AS IK JOIN ( SELECT InvId, LopNr, MAX(kal_datum) as LastKal FROM dbo.Inventarie_Kalibrering GROUP BY InvId, LopNr ) AS X ON X.InvId = IK.InvId AND X.LopNr = IK.LopNr AND X.LastKal = IK.kal_datumORDER BY InvId, LopNr
There will be duplicates if is is possible to have multiple InvId, LopNr with the exact same dateKristen