-1

I want to remove duplicate rows in my table. There is a unique column dataframeid. According to the dataframeid, I want to remove duplicate records

Same records shows up 5 times.

Table - OLTMS_5B0395

Sample data

id  DataFrameId DId OT  WT  AT  RC  YC  BC  RV  YV  BV  Oa  Aa  Gt  G   M   P   S   Ot  O   FCNT    RSSI    SF  SNR Rec
2391    1525345797494   4   0   0   35  338 333 664 245 244 245 0   0   0   0   0   0   0   0   0   1243    -92 12  -18 2018-03-05 16:39:00
2459    1525345797494   4   0   0   35  338 333 664 245 244 245 0   0   0   0   0   0   0   0   0   1243    -92 12  -18 2018-03-05 16:39:00
2282    1525345797494   4   0   0   35  338 333 664 245 244 245 0   0   0   0   0   0   0   0   0   1243    -92 12  -18 2018-03-05 16:39:00
2300    1525345797494   4   0   0   35  338 333 664 245 244 245 0   0   0   0   0   0   0   0   0   1243    -92 12  -18 2018-03-05 16:39:00
2338    1525345797494   4   0   0   35  338 333 664 245 244 245 0   0   0   0   0   0   0   0   0   1243    -92 12  -18 2018-03-05 16:39:00

Expected output

 2282   1525345797494   4   0   0   35  338 333 664 245 244 245 0   0   0   0   0   0   0   0   0   1243    -92 12  -18 2018-03-05 16:39:00

id that can be anything but there shouldn't be any duplicate records.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
krishna mohan
  • 133
  • 1
  • 2
  • 11

1 Answers1

0

As per o/p all columns have duplicate values so, you can use row_number() function

delete t from (
     select *,
            row_number() over (partition by DataFrameId,. . . order by id) Seq 
     from OLTMS_5B0395
) t
where Seq > 1;

Be aware with order by clause in row_number() function, include column in partition by clause where you got the duplicate values

Yogesh Sharma
  • 49,870
  • 5
  • 26
  • 52