In SQL, how would you write a query to find duplicate records and keep only the latest row per group?