| Author |
Topic |
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-06-14 : 04:26:06
|
| Hi..in my table there are duplicates records,from this i would like to delete 2 rows out of 3,if there any deff between row_count or inserts or updates i know how to delete but in this case could you pls tell me how to delete the 2 unwanted rows.TABLE_NAME ROW_COUNT INSERTS UPDATES SYS_DATEEMP_DETAILS 1586240 23 1586240 2010-06-13 EMP_DETAILS 1586240 23 1586240 2010-06-13 EMP_DETAILS 1586240 23 1586240 2010-06-13 thanxSatya |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-06-14 : 04:30:08
|
DELETE fFROM (SELECT ROW_NUMBER() OVER (PARTITION BY TABLE_NAME, ROW_COUNT, INSERTS, UPDATES, SYS_DATE ORDER BY SYSDATE) AS recID) AS fWHERE recID > 1 N 56°04'39.26"E 12°55'05.63" |
 |
|
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-06-14 : 04:37:27
|
| thanx fro ur reply peso,in mytable there is no columnname like ROW_NUMBERand u mentioned 'f' in the script it should be replace with actual table name right?thanxSatya |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-14 : 04:51:32
|
| If you use version 2005 or above,just use DELETE fFROM (SELECT ROW_NUMBER() OVER (PARTITION BY TABLE_NAME, ROW_COUNT, INSERTS, UPDATES, SYS_DATE ORDER BY SYSDATE) AS recID FROM your_table) AS fWHERE recID > 1Replace your_table with your actual tableMadhivananFailing to plan is Planning to fail |
 |
|
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-06-14 : 05:45:42
|
| Thanx madhivanan,i am able to clear duplicates on 2010-06-13,and the same issue on some of the previous dates aswell in my table,can i know how to clear the duplicates on previous dates pls.thanxSatya |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-06-14 : 05:54:56
|
The above query removes all duplicates regardless of date.If the date is not part of your key, remove sys_date from the partition clause. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-06-14 : 06:10:06
|
| when i run this script select * from (select table_name, run_date, count(*) as cntfrom EMP_DETAILS_TOTALRECORDSgroup by table_name, run_date) inqwhere cnt > 1order by table_name, run_dateEMP_PAS_ADM_REASON 2010-05-25 00:00:00.000 2EMP_PAS_ADM_SOURCE 2010-05-25 00:00:00.000 2EMP_PAS_ADM_TYPE 2010-05-25 00:00:00.000 2EMP_PAS_ADMISSIONS 2010-05-25 00:00:00.000 2EMP_PAS_ADMISSIONS1 2010-05-25 00:00:00.000 2EMP_PAS_ALERT_CODE 2010-06-11 00:00:00.000 2EMP_PAS_ALERT_CODES 2010-06-11 00:00:00.000 3there are still showing duplicates for the above tables,but manages to clear duplicates on 2010-06-13.last column '2' n '3' indicates no_of duplicates in each table on that perticular date.Satya |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-06-14 : 06:44:14
|
Are TABLE_NAME and RUN_DATE your key columns?DELETE fFROM (SELECT ROW_NUMBER() OVER (PARTITION BY TABLE_NAME, SYS_DATE ORDER BY SYSDATE DESC) AS recIDFROM EMP_DETAILS_TOTALRECORDS) AS fWHERE recID > 1 N 56°04'39.26"E 12°55'05.63" |
 |
|
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-06-14 : 10:32:47
|
| thanx for ur reply peso,actually i need to delete those manually based on no_of_updates becase no_of_updates are not duplicates in my table, the above script is used to delete any duplicates in all the columns.anyway..sorted now...thanxSatya |
 |
|
|
|