Query on deletion of duplicate data based on insertion time

Hi All,
I have loaded nearly 3 crore records in a table using SQL*Loader
(There are four datafiles)
Nearly 10 Lakhs records of a particular data file are duplicated on the database due to loading it by mistake another time.
Table has no constraints defined on it.
I know the approximate insertion time of the records.
Is there any way to find the rows based on insertion time and delete those duplicate rows?
Thanks,
Kishore

What version of Oracle? If you are on 10g and you created the tables to enable row movement and the loads were relatively recent, you may still be able to convert the ORA_ROWSCN pseudocolumn to a time and identify the rows that way. If you're on an earlier version, you didn't specify ENABLE ROW MOVEMENT when you created the table, or you did the load some time ago, you're probably out of luck.
If you're in ARCHIVELOG mode and you were doing logged loads and you still have the archived logs from the time period in question, you may be able to use LogMiner to identify the rows in question. I'd wager, though, that it would be faster just to query the table looking for duplicate rows and delete those rows.
Justin

Similar Messages

  • How to delete the duplicate data  from PSA Table

    Dear All,
    How to delete the duplicate data  from PSA Table, I have the purchase cube and I am getting the data from Item data source.
    In PSA table, I found the some cancellation records for that particular records quantity  would be negative for the same record value would be positive.
    Due to this reason the quantity is updated to target but the values would summarized and got  the summarized value  of all normal and cancellation .
    Please let me know the solution how to delete the data while updating to the target.
    Thanks
    Regards,
    Sai

    Hi,
    in deleting the records in PSA table difficult and how many you will the delete.
    you can achieve the different ways.
    1. creating the DSO maintain the some key fields it will overwrite the based on key fields.
    2. you can write the ABAP logic deleting the duplicate records at info package level check with the your ABAPer.
    3.you can restrict the cancellation records at query level.
    Thanks,
    Phani.

  • Query to delete look up data

    Guys ,
    Can anyone post the sql query to delete the look up data from DB .
    Thanks

    Buddy ,
    I simply need to clean up the data from DB , I will have to write some code and execute it to do that .
    I am not writing any functionality to delete look up data .
    Via query , i wud simply login to the db and delete the rows
    Thanks

  • How to delete the duplicate data in between two distinct rows in SQL?

    Hi,
    I need to identify the duplicate data with two distinct rows. See my data structure below.
    NAME NAME_1 VALUE START_DATE END_DATE FLAG INDEX
    SUR SE 275 13/12/2005 31/12/2010 B 1
    SUR SE 375 A 1
    SUR SE 475 A 1
    SUR SE 275 13/12/2005 31/12/2010 B 2
    SUR SE 375 A 2
    SUR SE 475 A 2
    SUR SE 175 13/12/2006 31/12/2010 B 3
    SUR SE 375 A 3
    SUR SE 475 A 3
    This is my sample data. Here data are duplicate with different index columns. INDEX 1 and 2 contains same group of combination. So i need to identify any one of duplicate combination(i.e INDEX 1 or 2). Can anyone come up with exact solution?
    Thanks

    Try this:
    with test_table as
    (select 'SUR' NAME, 'SE' NAME_1, 275 VALUE, '13/12/2005' START_DATE, '31/12/2010' END_DATE, 'B' FLAG, 1 IND from dual union all
    select 'SUR', 'SE', 375, null, null, 'A', 1 from dual union all
    select 'SUR', 'SE', 475, null, null, 'A', 1 from dual union all
    select 'SUR', 'SE', 275, '13/12/2005' ,'31/12/2010' ,'B', 2 from dual union all
    select 'SUR', 'SE', 375, null, null, 'A', 2 from dual union all
    select 'SUR', 'SE', 475, null, null, 'A', 2 from dual union all
    select 'SUR', 'SE', 175, '13/12/2006', '31/12/2010', 'B', 3 from dual union all
    select 'SUR', 'SE', 375, null, null, 'A', 3 from dual union all
    select 'SUR', 'SE', 475, null, null, 'A', 3 from dual )
    select t.*,
           CASE WHEN START_DATE IS NULL THEN
             first_value(row_number) OVER (PARTITION BY NAME, NAME_1, IND ORDER BY START_DATE)
           ELSE
             row_number
           END row_number
    from (
    SELECT t.*,
           CASE WHEN START_DATE IS NOT NULL THEN
             row_number() over(PARTITION BY NAME, NAME_1,VALUE, START_DATE, END_DATE, FLAG
                               ORDER BY IND)
           END row_number
      FROM test_table t) t
    order by IND, start_dateNote that this is only checking for diferences in the rows where start_date is not null. Do you want to also check if the records where start_date is null it there are differences? If so you can do this:
    with test_table as
    (select 'SUR' NAME, 'SE' NAME_1, 275 VALUE, '13/12/2005' START_DATE, '31/12/2010' END_DATE, 'B' FLAG, 1 IND from dual union all
    select 'SUR', 'SE', 375, null, null, 'A', 1 from dual union all
    select 'SUR', 'SE', 475, null, null, 'A', 1 from dual union all
    select 'SUR', 'SE', 275, '13/12/2005' ,'31/12/2010' ,'B', 2 from dual union all
    select 'SUR', 'SE', 375, null, null, 'A', 2 from dual union all
    select 'SUR', 'SE', 475, null, null, 'A', 2 from dual union all
    select 'SUR', 'SE', 175, '13/12/2006', '31/12/2010', 'B', 3 from dual union all
    select 'SUR', 'SE', 375, null, null, 'A', 3 from dual union all
    select 'SUR', 'SE', 475, null, null, 'A', 3 from dual )
    SELECT t.*,
           MIN(row_number) OVER(PARTITION BY NAME, NAME_1, IND) MIN
      FROM (SELECT t.*,
                   row_number() over(PARTITION BY NAME, NAME_1, VALUE,
                                                  START_DATE, END_DATE, FLAG
                                         ORDER BY IND) row_number
              FROM test_table t) t
    ORDER BY IND,
              start_date;Edited by: Manuel Vidigal on 13/Abr/2009 12:05

  • How to calculate Goods issue date based on the time of delivery

    Hi SAP Gurus,
    I seek your help/suggestion for the given scenario.
    The user requires calculating the GI date based on time of delivery.
    Based on the delivery priority (like Priority 1= Day 1, Priority 2= Day 2) maintained in customer master, the need is something like below-
    1st case= If Retail Customeru2019s delivery orders received before midday (Noon cut off) require to be dispatched on same working day (Day 1)
    Wholesaler customer delivery orders received before midday require to be dispatched by the next
    Working day (Day 2 Including day of receipt)
    2nd case= Retail customeru2019s delivery orders received after midday require to be dispatched by the next working day
    Wholesaler customer delivery orders received after midday require to be dispatched by on day 3
    Kindly suggest , how to proceed in this. I am new to SAP world so need ur help to tackle this.
    Thanks a lot in advance for the valuable inputs.

    What I proposed to do was,
    a. Create routes like 0 day route, 1 Day route, 2 day route etc.
    b. Route determination is based on the Shipping condition of the customer. Put in the shipping condition for the customer as 00 - immediate delivery. 01 - By Truck, 02 - By Rail, 03 - Ship etc
    c. Now, put in your route determination in such a way that routes change in the sales order with shipping condition (SC). Like, if the shipping condition is set to 00, then 0 day route comes up. Meaning immediate delivery, if SC is 01, then your normal route by truck picks up. etc.
    When the sales order is manually created, you know the time of creation. As route is one of the criteria, the material confirmation happens based on number of days you put in the route to reach the destination. Now that you have the material available for today's delivery, the delivery program can be run to create it, or it can be manually created.
    Now, when you configure the route you have to specify 'Transit duration in calendar days'.
    When you have the sales order created electronically (say thru EDI), then, you may have to ask them to send in shipping condition. Else, you have to modify the function module Idoc_input_orders in such a way that if the sales order creation time is < 12 PM, then put shipping condition as 00, else copy what ever is there in the customer.
    If you do not want to check the time manually when the user creates the sales order, then you may have to use the user exit MV45AFZZ (and I think you can use Save_order_prepare) to check the time and change the shipping condition. By this you will avoid extra coding in Idoc_input_orders and also need not bother if the user changed the route or not.
    Hope my explanation helps.
    Regards,
    Mukund S

  • Overriding the default "date-based" restrictions in time reporting

    Hi all.
    When using CATS/ESS for reporting time on tasks / roles there are some built in date based rules which limits when time reporting is possible.
    The cProjects 4.5 (SP05) help describes this as follows for a task-based set-up
    The system creates a worklist in CATS to enable you to record your time for a role or task. The system selects all objects (tasks, project roles, or project definitions) to which you are assigned in the confirmation time frame:
    If you set up confirmation via tasks, the worklist displays all tasks for confirmation to which your user is assigned by means of a role for the confirmation time frame and which have been released. For the confirmation time frame, the system first checks
    the time frame you specified on the Staffing tab page. Then it checks the time frame you specified in the Tasks Assigned to Selected Project Role group box on the Tasks tab page. If you only made entries on one of the tab pages, these apply.
    Put differently there is as I understand it a two-step check against the date that the user is trying to report on
    a) check against dates in staffing tab of role
    b) check against dates in the "tasks assigned to selected project role" tab of the role
    The requirement we are looking at now is to make this check a bit more loose.  An example could be to say that time reporting is OK as long as the dates lie within the projects scheduled dates.
    Any comments / experiences around this?  Possible?  I assume one would need to try to influence how the worklist is built up.
    Best regards / Anders

    Hi Anders,
    The building up the CATS worklist is done in two side, ERP system and cProject system. Regarding your requirment I think, the logic is done in cProject side, where the logic is hard coded and no Badi to enhance it.
    Please see my report in the Wiki to have more details:
    https://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action&pageid=61926
    Kind regards,
    Zhenbo

  • Query to find duplicate datas

    Hi,
    can any one help me the query to find the duplicate data from a column.

    maybe this example might be of some help.
    SQL> select * from employees;
    YEAR EM NAME       PO
    2001 04 Sarah      02
    2001 05 Susie      06
    2001 02 Scott      91
    2001 02 Scott      01
    2001 02 Scott      07
    2001 03 Tom        81
    2001 03 Tom        84
    2001 03 Tom        87
    8 rows selected.
    SQL> -- based on the output above we know that there is duplicates on scott and tom
    SQL> -- now we need to identified how many are duplicates by grouping into year, empcode, and name
    SQL> select year, empcode, name, position,
      2         row_number() over (partition by year, empcode, name
      3                            order by year, empcode, name, position) as rn,
      4         count(*) over (partition by year, empcode, name) as cnt
      5   from employees;
    YEAR EM NAME       PO         RN        CNT
    2001 02 Scott      01          1          3
    2001 02 Scott      07          2          3
    2001 02 Scott      91          3          3
    2001 03 Tom        81          1          3
    2001 03 Tom        84          2          3
    2001 03 Tom        87          3          3
    2001 04 Sarah      02          1          1
    2001 05 Susie      06          1          1
    8 rows selected.
    SQL> -- we have identified the duplicates on the above outputs by the counts
    SQL> -- now we want to query only rows that has duplicates
    SQL> select emp.year, emp.empcode, emp.name, emp.position, emp.cnt
      2    from (select year, empcode, name, position,
      3                 row_number() over (partition by year, empcode, name
      4                                    order by year, empcode, name, position) as rn,
      5                 count(*) over (partition by year, empcode, name) as cnt
      6            from employees) emp
      7   where rn = 1
      8     and cnt > 1;
    YEAR EM NAME       PO        CNT
    2001 02 Scott      01          3
    2001 03 Tom        81          3
    SQL>

  • Deleting duplicate data

    Hi,
    I have TABLE_A that acts as a look up table. It contains col1 and col2 with almost 50000 records. Previously the table has no unique constraint so there are lots of duplicate data.I've extracted the data by script below.
    SELECT * FROM TABLE_A WHERE col1 IN (SELECT col1 FROM TABLE_A GROUP BY col1 HAVING COUNT(col1) > 1)
    For your info heres my Table structure
    TABLE_A
    col1     col2
    A1234     86
    A1235     92          
    A1236     120
    A1237     45
    A1238     63
    A1238     63 --> to be deleted
    A1239      22
    How can I delete those duplicate data ? Thanks
    null

    <s> SELECT * </s> DELETE FROM TABLE_A
    WHERE col1 IN (SELECT col1 FROM TABLE_A
                             GROUP BY col1
                             HAVING COUNT(col1) > 1)
    Doesnt work?
    Message was edited by:
            jeneesh
    Oh , sorry..
    You want to delete only one of them..
    So,
    <br>
    <br>
    DELETE FROM TABLE_A
    WHERE rowid NOT IN (SELECT max(rowid) FROM TABLE_A
                             GROUP BY col1

  • Query to return next 7 dates

    Hello,
    is there a way to return the next 7 dates just using a query... for example, I need a query that returns:
    select (I don't know that put here) from dual
    Date
    2012-10-05
    2012-10-06
    2012-10-07
    2012-10-08
    2012-10-09
    2012-10-10
    2012-10-11
    If possible, I would like to know if there's a way to pass a date and based on it, the query returns the next 7 dates based on the passed date... for example:
    select (I don't know that put here) from dual where date > '2012-10-15'
    Date
    2012-10-16
    2012-10-17
    2012-10-18
    2012-10-19
    2012-10-20
    2012-10-21
    2012-10-22
    I really appreciate any help
    Thanks

    Sven W. wrote:
    I don't like connect by. That is fair enough, it is just your opinion.
    It is slow and shouldn't be used for real production code.This however, is absolute garbage.
    Changing the query to return 10,000 dates takes a little over 1s
    SQL> select date '2012-10-15' + level - 1 from dual
      2  connect by level <= 10000;
    <snip>
    28-FEB-40
    29-FEB-40
    01-MAR-40
    10000 rows selected.
    Elapsed: 00:00:01.26>
    In your case you can simply do this
    with inputdata as (select to_date('2012-10-15','yyyy-mm-dd') startday from dual)
    select startday+1 from inputdata union all
    select startday+2 from inputdata union all
    select startday+3 from inputdata union all
    select startday+4 from inputdata union all
    select startday+5 from inputdata union all
    select startday+6 from inputdata union all
    select startday+7 from inputdata ;
    Running your alternative for 10,000 dates took quite some time to create, needed to be put in a file to execute and has been running now for about 15 minutes
    select date '2012-10-15' + 1 from dual union all
    select date '2012-10-15' + 2 from dual union all
    <snip>
    select date '2012-10-15' + 9996 from dual union all
    select date '2012-10-15' + 9997 from dual union all
    select date '2012-10-15' + 9998 from dual union all
    select date '2012-10-15' + 9999 from dual union all
    select date '2012-10-15' + 10000 from dual
    ;It is much more code, takes more time to write, is proven to be incredibly slow and shouldn't be used for real production code.
    Edited by: 3360 on Oct 5, 2012 9:52 AM
    Sorry it took only 12 minutes, it seemed a lot longer when waiting for it
    29-FEB-40
    01-MAR-40
    01-MAR-40
    02-MAR-40
    10000 rows selected.
    Elapsed: 00:12:01.35

  • How to avoid duplicate data loading from SAP-r/3 to BI

    Hi !
           I have created one process chain that will load data into some ODS from R/3,where(in R/3)the datasources/tables r updated daily.
           I want to scheduled the system such that ,if on any day the source data is not updated (if the tables r as it is) then that data shuold not be loaded into ODS.
           Can any one suggest me such mechanism,so that I can always have unique data in my data targets.
           Pls ! Reply soon.
          Thank You !
           Pankaj K.

    Hello Pankaj,
    By setting the unique records option, you pretty much are letting the system know to not check the uniqueness of the records using the change log and the ODS active table log.
    Also, in order to avoid the problem where you are having dual requests which are getting activated at the same time. Please make sure you select the options "Set Quality Status to 'OK' Automatically" and "Activate Data Automatically" that way you would be having an option to delete a request as required without having to delete the whole data.
    This is all to avoid the issue where even the new request has to be deleted to delete the duplicate data.
    Untill and unless the timestamp field is available in the table on top of which you have created the datasource it would be difficult to check the delta load.
    Check the table used to make sure there is no timestamp field or any other numeric counter field which can be used for creating a delta queue for the datasource you are dealing with.
    Let me know if the information is helpful or if you need additional information regarding the same.
    Thanks
    Dharma.

  • Dates based on month

    Hi All,
    I want to write query which should return the dates based on the month i pass the to query .
    like example if pass to my query OCT-09 then it should return
    01-oct-09
    02-0ct-09
    31-oct-09.
    Can you please help me on this
    Thanks & regs
    -RG

    with tab as (
    select 10 mon,2009 yr from dual)
    select
    to_date(mon||'-'||yr,'mm-yyyy')+level-1 col
    from tab connect by level <=add_months(to_date(mon||' '||yr,'mm yyyy'),1)-to_date(mon||' '||yr,'mm yyyy')Ravi Kumar

  • Capture date change event of Time Refresh Control

    Hi,
    Is there any possible way by which we can capture the date change event from the time refresh control of iGrid?

    Hi,
    Ok lets do it this way.
    I have a page in which i am having radio button for date selection say YTD, MTD and so.
    In the page i have a frame in which an iGrid is coming up with some data based on the time period selected on the page.
    Now if i change the date from the time refresh control of the iGrid in the frame i want to uncheck the radio button seleted on the page as now its not YTD or MTD or whatever selected previously.
    Is there any possible way to do this?

  • Wrong data in cube for time dependent nav attribute

    Hi Experts,
    I am facing a strange problem.
    One of the navigational attr used in one cube was not time dependent before.
    Now we have changed it to time dependent.
    But after that the cube is fetching wrong data for the nav attr.
    In the Master data table (Q table) data is fine.
    Kindly suggest.
    Regards,
    Debjani

    Hi Debjani,
    As Federico said, when you display the content of the cube (or when you execute a query) you enter the reference date on which the time-dependant attribute will be searched. This unique reference date will be used whatever the cube data is.
    Ex :if the reference date is 2010/02/14, you will have the time-dep attribute value for 2010/02/14,for 2011 data, 2010 data or whatever.
    If you want to change dynamically the reference date depending on a date on the cube, things become a lot more difficult. The only possibility I can think of is "virtual characteristics" (you will find a lot of litterature on the subject on sdn).
    Regards,
    Fred

  • To eliminate date and extract only time component

    hi i am getting an input from a table which is of varchar2 type and the field has data like
    8:00 am-8:00 pm
    now i want to insert 8:00 am as start_time and 8:00 pm as end time in the columns start_time and end_time in another table.the 2 columns are of date type.
    HOW do i remove the date and just insert time in these columns
    because if i do
    insert into..
    to_date(substr(peak_time,1,7),'hh:mi am') ......
    then along with time current date gets appended.

    to be honest? If that was the requirement (eg. scheduling items to run between two times), I'd store it as numbers - probably as minutes. - eg. 8 hours = 8*60 minutes
    Then I'd do something like:
    select my_date + start_time_in_mins/1440 from my_table

  • SQL query and Delete the data based on condition

    Hi All,
    I have one requirement like I need to fetch the data from the table, In that table one filed (XXXXX) domain type is STAMP.
    delete the data if the sy-datum ( length 8) is greater than field XXXXX  which has length 14.
    Please suggest me how to delete or fetch the data with the same length.
    I have used below code..but did not work..
    "Concatenate sy-datum '%'  into gv_var1.
    select *
       from DD03l
       into itab
    where XXXX like gv_var1."
    and tried this one as well
    1. DELETE itab WHERE XXXXX GT sy-datum.
    2. DELETE itab WHERE XXXXX GT gv_var1.

    Hi,
    When dates are in different formats you have to always convert them into one common format and then do the checks. Its better to convert the date in the variable into timestamp(using CONVERT DATE statement-look for abapdocu for its usage) and then compare it with the date on database.
    data: gv_var1  TYPE timestamp.
    convert date sy-datum into time stamp gv_var1.
    select *
    from DD03l
    into itab
    where XXXX like gv_var1.
    should work now.
    Hope this helps.
    Shwetha

Maybe you are looking for

  • How to form a URL dynamically in my portlet

    hi all, i have a requirement in weblogic portal 10.2,how do i form my URL dyncamically in my portlet which is as below I have a requirement to dynamically form my URL. Further suppose I have a left navigation portlet which has 3 links and right navig

  • Trying to create cmp correctly(auto-increment);error while running

    I am using the latest versions of Jboss(4.0.5.GA) and Lomboz(R-3.2-200610201336) along with SQL Server 2005 and Microsoft's SQL Server 2005 JDBC driver. Lomboz used xdoclet to create the java files based on the SQL table but it did not put anything i

  • How to persist my own properties using Behavior tracking events

    Problem: I am trying to generate behavior tracking events. Now what i want is:      To store my own properties in the database along with the existing ones defined for an event.      I am working with only 2 events,namely,ClickCampaignEvent and Displ

  • Connections in use in data-source

    Is there a way to find out how many connections are in use in the pool for a particular data source? I've gone through the Visualizer and JMX. I can find the configuration, but no MBEANS or metrics for how many connections are actually in use?

  • 1600 - can't set font back to black

    Hi, can anyone help.? I have a 1600 that my 11 year old kid seems to have changed colours or theme setting (she doesn't know), leaving the font displayed in white! Can't figure out how to get it set back to black, can't seem to get original colour sc