How to Delete duplicate Records in Table

CREATE GLOBAL TEMPORARY TABLE MyTable1 (
Name1 varchar2(100)
insert into MyTable1 values ('11');
insert into MyTable1 values ('11');
insert into MyTable1 values ('11');
insert into MyTable1 values ('11');
insert into MyTable1 values ('12');
insert into MyTable1 values ('12');
select * from MyTable1
I want to delete duplicate names from MyTable1..And after delete I should have 11 and 22 only.

I got the answer
delete from MyTable1
where rowid not in
(select max(rowid)
from MyTable1
group by Name1
having count(1) > 1
)

Similar Messages

  • How to delete duplicate records in 10 G.

    how to delete duplicate records in 10 G.

    --Here is one way to do it using a second table 
    create table temp1
    (col1 char(1));
    --Table created.
    insert into temp1 (col1) values('A');
    insert into temp1 (col1) values('B');
    insert into temp1 (col1) values('B');
    --1 row created.
    --1 row created.
    --1 row created.
    create table temp2 as select distinct * from temp1;
    --Table created.
    --now you have a second table with no duplicates
    --truncate your old table
    truncate table temp1;
    --Table truncated.
    --and reload it with data from the new table
    insert into temp1 select * from temp2;
    --2 rows created.
    --then drop the temp2 table
    drop table temp2

  • How to delete duplicate records in all tables of the database

    I would like to be able to delete all duplicate records in all the tables of the database. Many of the tables have LONG columns.
    Thanks.

    Hello
    To delete duplicates from an individual table you can use a construct like:
    DELETE FROM
        table_a del_tab
    WHERE
        del_tab.ROWID <> (SELECT
                                MAX(dups_tab.ROWID)
                          FROM
                                table_a dups_tab
                          WHERE
                                dups_tab.col1 = del_tab.col1
                          AND
                                dups_tab.col2 = del_tab.col2
                          )You can then apply this to any table you want. The only differences will be the columns that you join on in the sub query. If you want to look for duplicated data in the long columns themselves, I'm pretty sure you're going to need to do some PL/SQL coding or maybe convert them to blobs or something.
    HTH
    David

  • How to delete Duplicate records from the informatica target using mapping?

    Hi, I have a scenario like below: In my mapping I have a source, which may containg unique records or duplicate records. Source and target are different tables. I have a target in my mapping which contains duplicate records. Using Mapping I have to delete the duplicate records in the target table. Target table does not contain any surrogate key. We can use target table as a look up table, but target table cannot be used as source in the mapping. We cannot use post SQL.

    Hi All, I have multiple flat files which i need to load in a single table.I did that using indirect option at session level.But need to dig out on how to populate substring of header in name column in target table. i have two columns Id and Name. in all input file I have only one column 'id' with header like H|ABCD|Date. I need to populate target like below example. File 1                                    File2     H|ABCD|Date.                      H|EFGH|Date.1                                            42                                            5  3                                            6 Target tale: Id    Name1     ABCD2     ABCD3     ABCD4     EFGH5     EFGH6     EFGH can anyone help on what should be the logic to get this data in a table in informatica.

  • How to delete the record in Table

    Hi Guru's,
    i have Table which contain no.of Records.
    i want to deleted one record. if i go to Table maint.Generator....from table itself..
    how to do that... when we deleting the record. can we create new TR for that?
    can anybody tell me.
    Thanks in Advance,
    venkat

    Hi,
    it is answered, here for my table there is no Table Maint.Generator.
    i just explained how i have done it.
    i just simply gone into Debug mode. there
    code = Dele.
    i have given. then i came out from debug mode to Table. there i just got Delete button on application tool bar.
    i selected the record then icliked on Delete button.
    it is got deleted.
    But it is not asking for any new Transport Request.
    Regards,
    Venkat

  • How to delete Duplicate records in IT2006

    Dear Experts
    We have a situation like where we have duplicate records with same start and end dates in IT2006. This is because of the incorrect configuration which we have corrected now, but we need to do  a clean-up for the existing duplicate records. Any idea on how to clean it?  I ran report RPTKOK00 to find these duplicates but I could not delete the duplicate/inconsistenct record using report RPTBPC10 or HNZUPTC0, i Could only delete the deductions happened in the record.
    Is there any standard report/any other means of deleting the duplicate records created in IT2006?
    Thanks in advance for all your help.
    Regards
    Vignesh.

    You could probably use se16n to identify the duplicates and create the list of quotas to delete, and you could probably use t-code lsmw to write up a script to delete them, but be aware that you can't delete a Quota if it's been deducted from.
    You'd have to delete the Absence/Attendance first, then delete the Quota, then recreate the Absence/Attendance.

  • How to delete duplicate records in cube

    Hi,
    can u help me how to delete the duplicate records in my cube
    and tell me some predifined cubes and data sourcess for MM and SD modules

    Hi Anne,
    about "duplicate records" could you be more precise?.
    The must be at least one different Characteristic to distinguish one record from the other (at least Request ID). In order to delete Data from InfoCubes (selectively) use ABAP Report RSDRD_DELETE_FACTS (be carefull it does not request any confirmation as in RSA1 ...).
    About MM and SD Cubes see RSA1 -> Business Content -> InfoProvider by InfoAreas. See also for MetadataRepository about the same InfoProviders.
    About DataSources just execute TCode LBWE in you source sys: there you see all LO-Cockipt Extrators.
    Hope it helps (and if so remember reward points)
    GFV

  • How to delete duplicate entries in table for the object DNL_CUST_BASIS2

    Hi All,
    I am trying to download the object DNL_CUST_BASIS2.
    In the SMQ2 the status is SYSFAIL.
    I checked in the ST22 for dumps.It says about the error while accessing the table T006.
    While analysing this,i found some duplicate entries in the related tables of this object.
    Can somebody help me how to delete these duplicate entries?
    Thanks,
    Senthil.

    Delete them directly from the table using se16:
    select the entries in the classic view (not ALV or grid view).
    activate the debugger.
    press the view button. --> you'll enter in the debugger
    press F7
    locate the sy-ucomm variable & change it to "DELE".
    press F8
    delete the entries.
    Trick-shots
    but it works!
    Michael.

  • How to delete duplicate record in Query report

    Hi Experts,
    I had created an infoset and query in my sap, but I want to delete some duplicate records before the list out put.Please can we add some further codes in the Extras code to delete duplicates? And how do it? Would you please give me a simple brief.
    Joe

    Hi,
    You can try to restrict in the filter area in query designer with the values for characteristic which gives correct
    result.
    But still i would suggest that in the cube you keep not the duplicate records as this is not your requirement and giving
    you wrong result.
    So you can reload the correct records in the cube inorder to avoid such problems even in future.
    Regards,
    Amit

  • How to delete translations / records in table omlt and mlt1

    The customer has added some records to the translations, using DTW.
    Unfortunately, the customer has made a mistake and wants these records to be deleted.
    It is not possible to delete these records in DTW.
    It is concerning 297 rows, I can select those rows by using a query that joins omlt and mlt1
    If i use / in DTW, I can't delete the records
    Is there an other way to fix this problem?
    I have posted this question to SAP Support, but it's outside their scope.
    Therefor I try to post this question on the forum

    You may try a tool called B1TCH: /people/community.user/blog/2007/08/19/get-your-kicks-with-di-commander
    Thanks,
    Gordon

  • How to delete duplicate rows in a table

    hai,
    i have a table which consists of hunderds of records and contains duplicate records also. how can i delete duplicate records.
    thanks
    ravi

    This maybe a litle bit fast for deletion:-
    delete from emp where rowid in (
    2 SELECT rowid FROM emp
    3 group by rowid,empno,ename,job
    4 minus
    5 SELECT min(rowid) FROM emp
    6 group by empno,ename,job);

  • Regarding how to delete the record in internal table

    Hi experts ,
    how to delete the record in intarnal table after validating the data,
    if record contains invalid fields?
    i am giving my code see this and give me the answer?
    loop at it_data into wa_data .
    Validate  Cost Center
        READ TABLE it_kostl INTO wa_kostl WITH KEY kostl = wa_data-kostl BINARY SEARCH.
        IF sy-subrc NE 0.
          PERFORM update_error_log USING wa_data
                                         text-004.
        ENDIF.
    Validate source file material ( material number )
    loop at it_mara into wa_mara .
      read table it_ausp into wa_ausp with key atwrt = wa_data-i_matnr .
               if sy-subrc NE 0 .
       PERFORM update_error_log USING wa_data
                                           text-002.
    delete it_data-objek .
         else.
      read table it_mara into wa_mara with key  matnr = wa_ausp-objek .
           if sy-subrc EQ 0 .
           wa_data-objek = wa_mara-matnr.
           wa_data-matkl = wa_mara-matkl.
         ENDIF.
         Modify it_data from wa_data  .
      endif.
    *endloop.
    Validate unit of measure (unit)
        READ TABLE it_t006 INTO wa_t006 WITH KEY msehi = wa_data-unit .
        IF sy-subrc NE 0.
          PERFORM update_error_log USING wa_data
                                         text-003.
        endif.
    Validate delivery location ( storage location )
        READ TABLE it_lgort INTO wa_lgort WITH KEY del_loc = wa_data-del_loc.
        IF sy-subrc NE 0.
          PERFORM update_error_log USING wa_data
                                         text-001.
             if wa_data-flag ='x' .
          delete it_data from  wa_data .
        endif.
        ENDIF.
    endloop.

    Hi Naren,
    First get the index number of the IT_data table and store it in one variable whose declaration like this.
    data: tabix type sy-tabix.
    while reading the internal table it_data set the tabix variable.
    tabix = sy-tabix.
    Instead of  the above use below one.
    Delete it_data-objek
    Use the Below statement it will delete  the row from the internal table.
    Delete it_data-objek index tabix
    Thanks,
    Chidanand

  • How to choose in Delete Duplicates from internal table?

    Now I need to delete Duplicates from internal table,
    So at first I sort
    than I delete duplicate
    Sort itab1 BY Company_Code  Asset_No Capital_Date.
          DELETE ADJACENT DUPLICATES FROM itab1 COMPARING Company_Code  Asset_No  Capital_Date
    Company_Code
    Asset_No
    Capital_Date
    Remark
    BC35
    1515593
    20021225
    Helen
    BC35
    1515593
    20021225
    Common Asset
    BC35
    1515594
    20030109
    Judy
    BC35
    1515594
    20030109
    Common Asset
    But here comes my problem~If I want to delete the Common Asset in Remark Column,how I let it choose the right one to do it?

    Hi Jack
    Try the below coding..
    Report zsamp.
    types: begin of t_tab,
            comp_code(4) type c,
            ***_no(7) type n,
            cap_date type d,
            remark type string,
            end of t_tab.
    data: i_tab type TABLE OF t_tab,
           w_tab type t_tab.
    w_tab-comp_code = 'BC35'.
    w_tab-***_no = '1515593'.
    w_tab-cap_date = '20021225'.
    w_tab-remark = 'Helen'.
    append w_tab to i_tab.
    w_tab-comp_code = 'BC35'.
    w_tab-***_no = '1515593'.
    w_tab-cap_date = '20021225'.
    w_tab-remark = 'Common Asset'.
    append w_tab to i_tab.
    w_tab-comp_code = 'BC35'.
    w_tab-***_no = '1515594'.
    w_tab-cap_date = '20030109'.
    w_tab-remark = 'Judy'.
    append w_tab to i_tab.
    w_tab-comp_code = 'BC35'.
    w_tab-***_no = '1515594'.
    w_tab-cap_date = '20030109'.
    w_tab-remark = 'Common Asset'.
    append w_tab to i_tab.
    sort i_tab by remark.
    delete ADJACENT DUPLICATES FROM i_tab COMPARING remark.

  • How to delete a record from BSEG table

    Dear Experts,
    How to delete a record from BSEG table.
    If there possible to delete some records from transparent table ?
    Please help.
    Regards,
    Tan

    Hi,
    Deleting a record from a standard table can be done only if table maintenance exists - Cehck tcode - SM30.  But it is not advisable to delete records, coz the records may be dependent on many other tables.  If u delete in a single place, there may be chance that inconsistency in the data happens and hence will affect ur financial statements.
    Pls. assign points, if useful
    Regards,
    Sridevi

  • How to avoid Duplicate Records  while joining two tables

    Hi,
    I am trying to join three tables, basically two tables are same one is like history table, so I wrote a query like
    select
    e.id,
    e.seqNo,
    e.name,
    d.resDate,
    d.details
    from employees e,
    ((select * from dept)union(select * from dept_hist)) d
    join on d.id=e.id and e.seqno=d.seqno
    but this returing duplicate records.
    Could anyone please tell me how to avoid duplicate records of this query.

    Actually it is like if the record is processed it will be moved to hist table, so both table will not have same records and I need the record from both the tables so i have done the union of both the tables, so d will have the union of both records.
    But I am getting duplicate records if even I am distinct.

Maybe you are looking for

  • Validation and Read Only Problem

    Hello there, I have this problem. I have an item that I need to hide when the page runs, and this item needs to have a validation. So my question will be. How can I bypass the validation if the item is on read only? Any ideas? Regards

  • PR Overall Release Strategy Problem

    Hi Expert, I have set the following Characterisrtic Name: 1) ZPR_Release_Plant, Char : CEBAN-WERKS (Char format : 4) 2) ZPR_Release_DOC_Type , char : CEBAN-BSART (Char format : 4) 3) ZPR_Release_Pur_Grp, Char: CEBAN_EKGRP (Char format : 3) 4) ZPR_Rel

  • Look & Feel Icons   **NOT SUN REPOSITORY**

    Hi guys, I'm looking to enhance my application with some new icons. I know this one: http://java.sun.com/developer/techDocs/hi/repository/ but it's very limited and (to be real) simple. I'm looking for somthing more like this: http://developer.gnome.

  • How to resize a rectangle with an image?

    Hey, I am working on a MacBook, for me this combination would be "CMD" + "ALT" + "SHIFT" to resize the Rectangle AND the Image placed inside. How is this possible with Indesign script? I'm working with Javascript. Thanks really much in advance!! Best

  • Premiere 8.0 Welcome Screen will load the editor, but will not open a project...

    Hi all, this is a small issue but annoying to me... After the welcome screen comes up, I click on "Open Project" and then on a name of my project I would like to work with. After a few seconds, the welcome screen loads the project editor, but the scr