-1

I need to delete the exact duplicate records from a table with 30 columns. My data would look something as attached.Advance Thanks!!enter image description here

Lithu T.V
  • 19,955
  • 12
  • 56
  • 101
Dileep
  • 624
  • 3
  • 10
  • 20

2 Answers2

1

Your question I understood like this...

1) if you want to delete only one record from duplicate rows.In this case you need a column date with (current timestamp) in table

delete from tableName t1 where
t1.id in (SELECT     t2.id
         FROM         tableName t2
         where t1.id = t2.id and t1.date(timestamp) < t2.date(timestamp))

2) if you want delete complete duplicate rows

delete from tableName t1 where
t1.id in (SELECT     t2.id
         FROM         tableName t2
         group by t2.id
         having count(*) >1)
Narayan Yerrabachu
  • 1,714
  • 1
  • 19
  • 31
0

This one should work:

delete from <table>
where rowid IN (
     SELECT LEAD(rowid) OVER (PARTITION BY <col1>, <col2>,...,<coln> ORDER BY NULL) 
     FROM <table>
);

And of course Fiddle

Chorel
  • 362
  • 1
  • 13