You can use one or the other of the following. Both require SQL 2005 or later:-- 1.;WITH cte AS( SELECT *, ROW_NUMBER() OVER(PARTITION BY Id_Number ORDER BY last_extraction DESC) AS RN FROM Table_1)SELECT last_extraction, Id, Id_number, color, buyer, seller, ADDRESS, zip_code, telephone_number, countryINTO Final_TableFROM cteWHERE RN = 1;-- 2.SELECT b.last_extraction, b.Id, a.Id_number, b.color, b.buyer, b.seller, b.ADDRESS, b.zip_code, b.telephone_number, b.countryINTO Final_TableFROM Table_1aCROSS APPLY( SELECT TOP 1 * FROM Table_1 c WHERE c.Id_number = b.Id_number ORDER BY last_extraction DESC) b;