Identifying and reporting Duplicate rows from table

I want to fetch all the duplicate row from the table and need to report all of it.
I am trying to run the below query but and not getting the expected output. Please help me.
Query
SELECT * FROM ADDT_RPT_REQ A WHERE
TRIM(A.EMAIL_ADDR) IN
(SELECT TRIM(EMAIL_ADDR) FROM ADDT_RPT_REQ B
WHERE TRIM(B.EMAIL_ADDR) = TRIM(A.EMAIL_ADDR)
AND A.ph_num IN
(SELECT PH_NUM FROM ADDT_RPT_REQ B
WHERE TRIM(A.PH_NUM ) = TRIM(B.PH_NUM)
There are in all 7 columns in the table where id is Unique Id.
The expected output is something like.
FST_NAME     LAST_NAME     EMAIL_ADDR     WORK_PH_NUM     ROW_ID     LAST_UPD     BU_ID
VALERIE     HALL     [email protected]     7819370177     2-21N-4312     31-AUG-04     0-R9NH
VALERIE     HALL     [email protected]     7819373737     2-21N-4327     29-JAN-04     0-R9NH
VALERIE     HALL     [email protected]     6034272034     2-21N-4309     04-APR-03     0-R9NH
VALERIE     HALL     [email protected]     7819373737     2-21N-4317     04-APR-03     0-R9NH
VALERIE     HALL     [email protected]     8563748820     2-21N-4329     31-AUG-04     0-R9NH
VALERIE     HALL     [email protected]     7819373737     2-21N-4319     04-APR-03     0-R9NH
VALERIE     HALL     [email protected]     7819373737     2-21N-4326     04-APR-03     0-R9NH
VALERIE     HALL     [email protected]     7819373737     2-21N-4324     04-APR-03     0-R9NH
VALERIE     HALL     [email protected]     8604237395     2-21N-4330     31-AUG-04     0-R9NH
VALERIE     HALL     [email protected]     7819373731     2-21N-4314     31-AUG-04     0-R9NH
VALERIE     HALLORAN     [email protected]     6194771101     2-21N-4331     31-OCT-05     0-R9NH
VALERIE     HALL     [email protected]     7819373737     2-21N-4316     04-APR-03     0-R9NH
VALERIE     HALL     [email protected]     7819373737     2-21N-4321     04-APR-03     0-R9NH
VALERIE     HALL     [email protected]     7819373737     7-1W4N-293     15-MAY-04     0-R9NH
VALERIE     HALL     [email protected]     2032341604     2-21N-4307     31-AUG-04     0-R9NH
VALERIE     HALL     [email protected]     7819373737     2-21N-4325     04-APR-03     0-R9NH
VALERIE     HALL     [email protected]     7819373737     2-21N-4315     29-JAN-03     0-R9NH
VALERIE     HALL     [email protected]     7819373737     7-1W4N-291     15-MAY-04     0-R9NH
VALERIE     HALLORAN     [email protected]     6194771101     2-21N-4332     31-OCT-05     0-R9NH
VALERIE     HALL     [email protected]     6038885349     2-21N-4310     31-AUG-04     0-R9NH
VALERIE     HALL     [email protected]     7819373737324     2-21N-4328     31-AUG-04     0-R9NH
VALERIE     HALL     [email protected]     7819370177324     2-21N-4313     31-AUG-04     0-R9NH

Hi again!
Try that:
SELECT rowid, fst_name, last_name, email_addr, work_ph_num, row_id, last_upd, bu_id
FROM ADDT_RPT_REQ A
WHERE rowid > (SELECT MIN(rowid)
               FROM ADDT_RPT_REQ B
               WHERE B.fst_name = A.fst_name
                 AND B.last_name = A.last_name
                 AND B.email_addr = A.email_addr
                 AND B.work_ph_num = A.work_ph_num
                 AND B.row_id = A.row_id
                 AND B.last_upd = A.last_upd
                 AND B.bu_id = A.bu_id);This query should show you all duplicate rows. Use the rowid and DELETE to get rid of these rows.
DELETE FROM addt_rpt_req A
WHERE rowid IN (SELECT rowid
                FROM   (SELECT rowid, row_number() OVER (PARTITION BY fst_name, last_name, email_addr, work_ph_num, row_id, last_upd, bu_id
                                                         ORDER BY row_id) dup
                        FROM addt_rpt_req)
                        WHERE dup > 1);Yours sincerely
Florian W.
Edited by: Florian W. on 17.06.2009 14:17

Similar Messages

  • How to update duplicate row from table

    Hi,
    how to update duplicate row from table?
    First to find duplicate row then update duplicate row with no to that duplicate row in oracle.
    can you give me suggestion on it?
    Thanks in advance.
    your early response is appreciated...

    In order to find a duplicate row, see:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1224636375004
    (or search this forum, your question has been asked before)
    In order to update it, just create and use an Oracle sequence, have it start and increment at a value that doesn't exist in your table.
    If that doesn't get you going, post some CREATE TABLE + INSERT INTO statements, and the results you want from them, in other words: a complete testcase.

  • Duplicate rows from table

    i have a table A suppose it has 3 columns
    id name sal
    ==========
    1 A 100
    1 A 100
    2 B 200
    2 B 200
    2 B 200
    3 C 300
    I want to find duplicate rows from the above table without passing any column in to the where clause .
    please help me to find out this query.

    maybe you should try the database forum...

  • Selecting duplicate rows from table

    Hi all,
    How to select the duplicates rows present in the table...

    SQL> select * from customer;
    CUST_ID CUST_NAME LOC
    1 Jeff Miami
    2 Andrew Michigan
    3 Julia Chicago
    1 Linda Miami
    1 Martha Miami
    3 Randy Chicago
    3 John Chicago
    7 rows selected.
    SQL> select * from customer where rowid != (select min(rowid) from customer C where C.cust_id = customer.cust_id);
    CUST_ID CUST_NAME LOC
    1 Linda Miami
    1 Martha Miami
    3 Randy Chicago
    3 John Chicago
    SQL>

  • Need to remove duplicate rows from a table

    Hi Gurus ,
    I am using oracle 11.2.0.3 .
    SQL> desc osstage.S_EVT_ACT_X;
    Name                                      Null?    Type
    ROW_ID                                    NOT NULL VARCHAR2(15 CHAR)
    LAST_UPD                                  NOT NULL DATE
    PAR_ROW_ID                                NOT NULL VARCHAR2(15 CHAR)
    ATTRIB_17                                          NUMBER(22,7)
    ATTRIB_26                                          DATE
    ATTRIB_02                                          VARCHAR2(100 CHAR)
    PROCESS_TIMESTAMP                                  TIMESTAMP(6);
    now when i give the below command it gives the error as someone has disabled the constraint accidently .
    alter table s_evt_act_x enable constraint S_EVT_ACT_X_P1;
    Error starting at line 3 in command:
    alter table s_evt_act_x enable constraint S_EVT_ACT_X_P1
    Error report:
    SQL Error: ORA-02437: cannot validate (OSSTAGE.S_EVT_ACT_X_P1) - primary key violated
    02437. 00000 -  "cannot validate (%s.%s) - primary key violated"
    *Cause:    attempted to validate a primary key with duplicate values or null
               values.
    *Action:   remove the duplicates and null values before enabling a primary
               key.
    Can you please guide me with this issue .

    Please refer
    Script: Deleting Duplicate Rows from a Table (Doc ID 31413.1)
    How to Find or Delete Duplicate Rows in a Table (Doc ID 1004425.6)

  • First attempt to remove duplicate rows from a table...

    I have seen many people asking for a way to remove duplicate rows from data. I made up a fairly simple script. It adds a column to the table with the cell selected in it, and adds the concatenation of the data to the left into that new column. then it reads that into a list, and walks through that list to find any that are listed twice. Any that are it marks for DELETE.
    It then walks through to find each one marked for delete and removes them (you must go from bottom to top to do this, otherwise your row markings for delete don't match up to the original rows anymore). Last is to delete the column we added.
    tell application "Numbers"
    activate
    tell document 1
    -- DETERMINE THE CURRENT SHEET
    set currentsheetindex to 0
    repeat with i from 1 to the count of sheets
    tell sheet i
    set x to the count of (tables whose selection range is not missing value)
    end tell
    if x is not 0 then
    set the currentsheetindex to i
    exit repeat
    end if
    end repeat
    if the currentsheetindex is 0 then error "No sheet has a selected table."
    -- GET THE TABLE WITH CELLS
    tell sheet currentsheetindex
    set the current_table to the first table whose selection range is not missing value
    end tell
    end tell
    log current_table
    tell current_table
    set list1 to {}
    add column after column (count of columns)
    set z to (count of columns)
    repeat with j from 1 to (count of rows)
    set m to ""
    repeat with i from 1 to (z - 1)
    set m to m & value of (cell i of row j)
    end repeat
    set value of cell z of row j to m
    end repeat
    set MyRange to value of every cell of column z
    repeat with i from 1 to (count of items of MyRange)
    set n to item i of MyRange
    if n is in list1 then
    set end of list1 to "Delete"
    else
    set end of list1 to n
    end if
    end repeat
    repeat with i from (count of items of list1) to 1 by -1
    set n to item i of list1
    if n = "Delete" then remove row i
    end repeat
    remove column z
    end tell
    end tell
    Let me know how it works for y'all, it worked good on my machine, but I know localization is causing errors sometimes when I post things.
    Thanks,
    Jason
    Message was edited by: jaxjason

    Hi jason
    I hope that with the added comments it will be clear.
    Ask if something is always opaque.
    set {current_Range, current_table, current_Sheet, current_Doc} to my getSelection()
    tell application "Numbers09"
    tell document current_Doc to tell sheet current_Sheet to tell table current_table
    set list1 to {}
    add column after column (count of columns)
    set z to (count of columns)
    repeat with j from 1 to (count of rows)
    set m to ""
    tell row j
    repeat with i from 1 to (z - 1)
    set m to m & value of cell i
    end repeat
    set value of cell z to m
    end tell
    end repeat
    set theRange to value of every cell of column z
    repeat with i from (count of items of theRange) to 1 by -1
    (* As I scan the table backwards (starting from the bottom row),
    I may remove a row immediately when I discover that it is a duplicate *)
    set n to item i of theRange
    if n is in list1 then
    remove row i
    else
    set end of list1 to n
    end if
    end repeat
    remove column z
    end tell
    end tell
    --=====
    on getSelection()
    local _, theRange, theTable, theSheet, theDoc, errMsg, errNum
    tell application "Numbers09" to tell document 1
    set theSheet to ""
    repeat with i from 1 to the count of sheets
    tell sheet i
    set x to the count of tables
    if x > 0 then
    repeat with y from 1 to x
    (* Open a trap to catch the selection range.
    The structure of this item
    «class
    can't be coerced as text.
    So, when the instruction (selection range of table y) as text
    receive 'missing value' it behaves correctly and the lup continue.
    But, when it receive THE true selection range, it generates an error
    whose message is errMsg and number is errNum.
    We grab them just after the on error instruction *)
    try
    (selection range of table y) as text
    on error errMsg number errNum (*
    As we reached THE selection range, we are here.
    We grab the errMsg here. In French it looks like:
    "Impossible de transformer «class
    The handler cuts it in pieces using quots as delimiters.
    item 1 (_) "Impossible de transformer «class » "
    item 2 (theRange) "A2:M25"
    item 3 (_) " of «class NmTb» "
    item 4 (theTable) "Tableau 1"
    item 5 (_) " of «class NmSh» "
    item 6 (theSheet) "Feuille 1"
    item 7 (_) " of document "
    item 8 (theDoc) "Sans titre"
    item 9 ( I drop it ) " of application "
    item 10 ( I drop it ) "Numbers"
    item 11 (I drop it ) " en type string."
    I grab these items in the list
    {_, theRange, _, theTable, _, theSheet, _, theDoc}
    Yes, underscore is a valid name of variable.
    I often uses it when I want to drop something.
    An alternate way would be to code:
    set ll to my decoupe(errMsg, quote)
    set theRange to item 2 of ll
    set theTable to item 4 of ll
    set theSheet to item 8 of ll
    set theDoc to item 10 of ll
    it works exactly the same but it's not so elegant.
    set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
    exit repeat (*
    as we grabbed the interesting datas, we exit the lup indexed by y.*)
    end try
    end repeat -- y
    if theSheet > "" then exit repeat (*
    If we are here after grabbing the datas, theSheet is not "" so we exit the lup indexed by i *)
    end if
    end tell -- sheet
    end repeat -- i
    (* We may arrive here with two kinds of results.
    if we grabbed a selection, theSheet is something like "Feuille 1"
    if we didn't grabbed a selection, theSheet is the "" defined on entry
    and we generate an error which is not trapped so it stops the program *)
    if theSheet = "" then error "No sheet has a selected table."
    end tell -- document
    (* Now, we send to the caller the interesting datas :
    theRange "A2:M25"
    theTable "Tableau 1"
    theSheet "Feuille 1"
    theDoc "Sans titre" *)
    return {theRange, theTable, theSheet, theDoc}
    end getSelection
    --=====
    on decoupe(t, d)
    local l
    set AppleScript's text item delimiters to d (*
    Cut the text t in pieces using d as delimiter *)
    set l to text items of t
    set AppleScript's text item delimiters to "" (*
    Resets the delimiters to the standard value. *)
    (* Send the list to the caller *)
    return l
    end decoupe
    --=====
    Have fun
    And if it's not clear enough, you may ask for more explanations.
    Yvan KOENIG (from FRANCE mardi 27 janvier 2009 21:49:19)

  • How to identify and remove duplicate plugin effects from AE cs5 please?

    hello,
    i installed some trial plug in effects for AE and PPRO cs5
    cycore, boris, trapcode
    the PPRo went great
    however, with the AE i get notices that multiple instances of 'such and such' effect
    is installed more than one time...there's about 15 that give me a warning each time i start AE...
    i tried my best to locate any duplicates but no luck
    How do you identify and remove duplicate plug in effects for AE CS5?
    thanks,
    j

    hello,
    it is nice when you can answer your own question...
    looked in 'common...media core...' and found the new blue trial plugins
    also had the duplicates of the new blue plugins in the AE plugins 'effects' folder
    deleted the plugins from the 'media core' folder
    no more warning signs...
    cool deal
    back to work,
    j

  • Deleting rows from table based on value from other table

    Hello Members,
    I am struck to solve the issue said below using query. Would appreciate any suggestions...
    I have two tables having same structures. I want to delete the rows from TableA ( master table ) with the values from TableB ( subset of TableA). The idea is to remove the duplicate values from tableA. The data to be removed are present in TableB. Catch here is TableB holds one row less than TableA, for example
    Table A
    Name Value
    Test 1
    Test 1
    Test 1
    Hello 2
    Good 3
    TableB
    Name Value
    Test 1
    Test 1
    The goal here is to remove the two entries from TableB ('Test') from TableA, finally leaving TableA as
    Table A
    Name Value
    Test 1
    Hello 2
    Good 3
    I tried below queries
    1. delete from TestA a where rowid = any (select rowid from TESTA b where b.Name = a.Name and a.Name in ( select Name from TestB ));
    Any suggestions..
    We need TableB. The problem I mentioned above is part of process. TableB contains the duplicate values which should be deleted from TableA. So that we know what all values we have deleted from TableA. On deleted TableA if I later insert the value from TableB I should be getting the original TableA...
    Thanks in advance

    drop table table_a;
    drop table table_b;
    create table  table_b as
    select 'Test' name, 1 value from dual union all
    select 'Test' ,1 from dual;
    create table table_a as
    select 'Test' name, 1 value from dual union all
    select 'Test' ,1 from dual union all
    select 'Test' ,1 from dual union all
    select 'Hello' ,2 from dual union all
    select 'Good', 3 from dual;
    /* Formatted on 11/23/2011 1:53:12 PM (QP5 v5.149.1003.31008) */
    DELETE FROM table_a
          WHERE ROWID IN (SELECT rid
                            FROM (SELECT ROWID rid,
                                         ROW_NUMBER ()
                                         OVER (PARTITION BY name, VALUE
                                               ORDER BY NULL)
                                            rn
                                    FROM table_a a
                                   WHERE EXISTS
                                            (SELECT 1
                                               FROM table_b b
                                              WHERE a.name = b.name
                                                    AND a.VALUE = b.VALUE))
                           WHERE rn > 1);
    select * from table_a
    NAME     VALUE
    Test     1
    Hello     2
    Good     3Edited by: pollywog on Nov 23, 2011 1:55 PM

  • Removing duplicate rows from SELECT

    Hi, I was wondering if there was any way to remove duplicate rows from a select statement.
    My table looks like this:
    CREATE TABLE CUS_ID_TO_PC_ID (
    CUSTOMER_ID VARCHAR2 (10) NOT NULL,
    PC_ID VARCHAR2 (25) NOT NULL,
    PASSWORD VARCHAR2 (25) NOT NULL,
    REG_DATE DATE,
    PRODUCT_DESC VARCHAR2 (25),
    EXPIRE_DATE DATE,
    SERIAL_NBR VARCHAR2 (12),
    LDAP_USER VARCHAR2 (200),
    COMMENTS VARCHAR2 (2000),
    PC_ID_5_4 VARCHAR2 (25),
    PC_ID_6_0 VARCHAR2 (25),
    PASSWORD_5_4 VARCHAR2 (25),
    PASSWORD_6_0 VARCHAR2 (25),
    PC_ID_6_1 VARCHAR2 (25),
    PASSWORD_6_1 VARCHAR2 (25),
    OPERATING_SYSTEM VARCHAR2 (20),
    STATUS VARCHAR2 (1)
    Basically, I want to retrieve all columns from the table but remove all duplicate variations of
    the pc_id/serial_nbr combinations.
    For example, given this data:
    PC_ID SERIAL_NBR CUSTOMER_NO
    1234567 AAA C345
    1234567 AAA C567
    3333333 BBB C456
    only the 1st and 3rd rows would be returned.
    Any ideas?

    Try something like this:
    select * from your_table yt
    where rowid in (select max(rowid)
    from your_tabel yt2
    where yt2.pc_id = yt.pc_id
    and yt2.serial_nbr = yt.serial_nbr);

  • How can I identify and delete duplicates on the latest version of itunes?

    How can I identify and delete duplicates on the lastest version of iTunes?

    The show duplicates/show exact duplicates features have been left out of iTunes 11. Rumor suggests they will be restored in the next build. In the meantime I have written two Windows scripts to make playlists of Duplicates and Exact Duplicates, either from a selection of tracks or the entire library. Note that, as with the iTunes feature, this list makes no distinction between "originals" and "dupes", you have to decide which is which.
    There is also my DeDuper script for automatically removing duplicate copies but keeping one remaining copy of each set. This can preserve ratings, play counts, playlist membership, etc. which are lost in a manual clean up. Please take note of the warning to backup your library before deduping. See this thread for background on deduping and the script.
    If you want to manually remove duplicate tracks use shift-delete to remove selected tracks from the library as well as the playlist. Keep one of each repeated group of files and don't send the others to the recycle bin unless you are sure that there are multiple files on the disc as opposed to multiple entries to the same file. Same advice to backup applies.
    tt2

  • How can I identify and remove duplicate file (audio & photo)

    How can I identify and remove duplicate file (audio & photo)?  I have quite a few libraries created as backup files.

    Terence,
    Yes, the duplicates appear in the iPhoto window. I have folders with same name occuring two or even three times sometimes with exactly the same set of photos (ie photos with the same ID) and sometimes with a limited set of photos. Other  folders appear only once.
    I normally take my MacBook with me if I'm shooting a lot of photos, such as on holiday, and then want to transfer them to my iMac when i get home. Other times I transfer the camera's memory stick directly to my iMac.
    I have great difficulty transferring the photos from my MacBook to my iMac. I don't want to store my photos on my iDisk due to the length of time it takes to upload them.
    Thanks again.
    Simon

  • Rerieve Duplicate Rows from a SELECT statement

    Hi, I want to see all the duplicate rows from my SELECT statement. Looks like Oracle by default suppresses the duplicate rows. Here is my SQL statement.
    I like to see all the 5 rows. Please help.
    select a.partid, a.pdesc
    from product a
    where a.partid in ('10-30000-4',
    '10-30000-4',
    '10-30000-4',
    '10-30000-4',
    '10-30000-5')

    Looks like Oracle by default suppresses the duplicate rowsSure no, if you have duplicate rows, Oracle will show you the dup rows.
    Please, paste your data and the query result.
    And this is no because you'll put multiple time the same condition that Oracle will show you multiple time the same row (in case of non-duplicate).
    Nicolas.

  • How can I identify and delete duplicate photos

    is there a way to identify and delete duplicate photo's in I photo?

    No one is suggesting that you download third party "crap". What was suggested is that you download a well established and supported 3rd party application. As to why there isn't a "'delete your stupid duplicate photo' option", you'll need to ask Apple that. Apple aren't here. This forum is for Users to help other Users. As to why you import stupid photos, you'll need to ask yourself.
    Regards
    TD

  • Add and Delete a row in table

    Hi Expert,
    In SAP interactive form OFFLINE Scneario.
    I have a deep structure. In which i am using other structures like kna1, knb1, knvv.
    Now in KNVV is again a deep structure in which i have a table type.
    Now a draged and droped this table type to my layout  so i got a table.
    I Need to have two buttons ADD and Delete, To add and delete a row in table repectvily.
    I saw other threads also but get not do it.
    My table type attribute's name in KNVV structure is VLACT.
    I write following code on click action of ADD button
    data.#subform[0].Button1::click: - (FormCalc, client) -
    VLACT.row.instanceManager.addInstance(1);
    xfa.form.recalculate(1);
    but it shows error msg
    accessor "VLACT.row.instanceManager.addInstance(1);"
    is unknown.
    Also i am not able to see tabel itself wich i draged and droped. Only two buttons are there.
    Plz help
    Thanks ? Regards,
    Arvind

    Hi Otto,
    This is the code i am using to add new row.
    Also all the settings in form are correct like "Repeat row for each data item" etc.
    I want to have at most 7 rows.
    var nTableLength = Table1.nodes.length; 
      var nNumRow = 0;
        for (var nCount = 0; nCount < nTableLength; nCount ++)
          if ((Table1.nodes.item(nCount).className == "subform") & (Table1.nodes.item(nCount).name !== "HeaderRow"))
           { nNumRow = nNumRow + 1; }
               if (nNumRow == 7)
               { xfa.host.messageBox("The maximum allowable number of rows is 7. You cannot add any more rows.", "Warning", 3); }
           else {
                  Table1.Row1.instanceManager.addInstance(1);
                  xfa.form.recalculate(1);
                   xfa.host.messageBox("row added" );
    I get the msg form the statment        xfa.host.messageBox("row added" );
    But i can not see the newly added row
    Plz help
    Thansks & Regards,
    Arvind

  • How do I identify and delete duplicate photos in iPhoto. It is so simple on iTunes

    How do I identify and delete duplicate photos in iPhoto? It is so simple on iTunes

    There really is no easier way than to use Duplicate Annihilator. It costs about $8.00 but will save you lots of time.

Maybe you are looking for

  • Reading an xml file in the web services java file

    I want to read some data in the webservices file.so i am writing my own xml file through which i want to read data.but i am not able to read xml file from web services file.also , i am not able to put xml file in the .ear file,as there is no such tag

  • Create pdf stopped working - WindowsXP-Office2003-Acrobat6

    After 3 years of creating pdfs just fine, I swear it seems like "it" just stopped working. Windows XP Media Edition - Service Pak 3 Office Professional 2003 Acrobat Standard 6.0 In any Office ap (word, excel, publisher, etc), if I do Print/Adobe PDF/

  • Every time I import an .fcpxml file into Final Cut Pro X, the timeline doesn't get imported

    So I had exported an .fcpxml file from one machine, which i had to format. So, after formatting the machine, each time I import the .fcpxml file into Final Cut Pro X, The timeline remains empty

  • Can someone help me here please?!?

    How come my iPhone 5s gets significantly less signal then my iPad air 64gb they are both running tmobile My iPad air just arrived today and I noticed that in areas where I would get 1-2 bars on my iPhone 5s I have 3 to 4 bars on my iPad air At the mo

  • Scaling Styles without Constrain Proportions

    Hi, I'm an artist and have paintings that I take digital images of and work on them in Photoshop cs4. The problem I have is that the images, when cut out from the background, are smaller than the actual painting and the aspect ratio (ratio of one sid