Deleting Duplicates

  • I have a table with near duplicates. Column1 has Name and Column2 has a date. I want to delete all the entries where the name in Column1 is duplicated, but I want to keep the entry with the newest date.

    Please Help

  • delete from a

      from TEST3 a join

         (select cust_id, max(tran_date) as max_tran_date from TEST3

                 group by cust_id

                 having count(*) > 1) b

          on a.cust_id = b.cust_id and a.tran_date < b.max_tran_date

  • Allen, can you please explain the statement.... there is only one table "A" where would test3 come from is that another temp table or something?? 

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply