Identify duplicate records in a table

I have this situation in the same table
GOREMAL_PIDM     GOREMAL_EMAL_CODE     GOREMAL_EMAIL_ADDRESS     GOREMAL_STATUS_IND     GOREMAL_PREFERRED_IND
2238954     REC1     [email protected]     A     Y
2238954     REC1     [email protected]     A     N
I need to identify those records (look they are the same(email address), just upper and lower case) then I need delete one the one with the GOREMAL_STATUS_IND = N
I am running this query
select
a.goremal_pidm    pidm_a,
b.goremal_pidm    pidmb,
a.goremal_emal_code emal_codea,
b.goremal_emal_code emal_codeb,
a.goremal_email_address email_addressa,
b.goremal_email_address email_addressb,
a.goremal_status_ind    status_inda,
b.goremal_status_ind    status_indb,
a.goremal_preferred_ind preferred_inda,
b.goremal_preferred_ind preferred_indb,
a.goremal_activity_date activity_datea,
b.goremal_activity_date activity_dateb,
a.goremal_user_id        user_ida,
b.goremal_user_id        user_idb,
a.goremal_comment        commenta,
b.goremal_comment        commentb,
a.goremal_disp_web_ind   web_inda,
b.goremal_disp_web_ind   web_indb,
a.goremal_data_origin    origina,
b.goremal_data_origin    originb
FROM
goremal a, goremal b, saradap
WHERE
--b.goremal_pidm = 2216086
b.goremal_preferred_ind = 'N'
AND a.goremal_preferred_ind = 'Y' 
AND  a.goremal_emal_code = 'REC1'
AND B.goremal_emal_code = 'REC1'
and a.goremal_email_address =  b.goremal_email_address
and a.goremal_pidm = b.goremal_pidm
and a.goremal_pidm = saradap_pidm
AND Saradap_term_code_entry = 200990
AND Saradap_program_1 = 'UBA' to identify the records but it is not working sometimes give me recoirds that only have one row in the table (goremall)
what will be a good way to do this, again I need to identify all the records that have 2 rows, but the email is the same then I need to delete the ones with the
GOREMAL_STATUS_IND = N
tHANK YOU

Hi,
user648177 wrote:
Sorry but the previous answer won't work
I need to be able to identify (before the delete) all the records
like this one
GOREMAL_PIDM     GOREMAL_EMAL_CODE     GOREMAL_EMAIL_ADDRESS     GOREMAL_STATUS_IND     GOREMAL_PREFERRED_IND
2238954     REC1     [email protected]     A     Y
2238954     REC1     [email protected]     A     N
where the GOREMAL_EMAL_CODE are equal and the GOREMAL_EMAIL_ADDRESS is Y in one record and N in another record, then I will delete the records with N, but I want to de a select before I do the deleteWhat is wrong with Mathiasm's suggestion? What exactly "won't work" when you try it?
It would help if you formatted the data so that the columns lined up and posted it between {code} tags.
It could be that there was some confusion about what the column names were, and you only have to substitute the right names for it to work.
If you want to see the rows that will be deleted, rather than actually deleting them, change "DELETE" to "SELECT *".

Similar Messages

  • Identifying duplicate records in a table

    I am trying to identify duplicate records in a table - well they are broadly duplicated but some of the fields are changed on each insert whilst others are always the same.
    I can't work out the logic and it is driving me #$%$#^@ crazy !

    Here are a couple of other examples:
    Method 1: -- Makes use of the uniqueness of Oracle ROWIDs to identify duplicates.
    =========
    To check for single column duplicates:
    select rowid, deptno
    from dept outer
    where
    outer.rowid >
    (select min(rowid) from dept inner
    where inner.deptno=outer.deptno)
    order by deptno;
    To check for multi-column (key) duplicates:
    select rowid, deptno, dname
    from dept outer
    where
    outer.rowid >
    (select min(rowid) from dept inner
    where inner.deptno| |inner.dname=outer.deptno| |outer.deptno)
    order by deptno;
    Method 2: -- Makes use of resultset groups to identify uniqueness
    =========
    To check for single column duplicates:
    select rowid, deptno
    from dept
    where
    deptno in
    (select deptno from dept group by deptno having count(*) > 1)
    order by deptno;
    To check for multi-column (key) duplicates:
    select rowid, deptno, dname
    from dept
    where
    deptno| |dname in
    (select deptno| |dname from dept group by deptno| |dname having count(*) > 1)
    order by deptno;
    null

  • Problem in identifying unique records from different tables

    Hello gurus,
    I am on E-Recruitment module.
    I order to get more fields in CANDIDATE_ATTR datasource I have enhanced it. I am getting additional fields from HRP5103 (Employer, Employment Start Date & Employment End Date) & from HRP5104 (Institute, City, Region). In both of the tables there are 9 primary keys out of which only two are different through which we can identify duplicate records i.e. OBJID (denote Candidate ID in both tables) & SEQNR(Number of Infotype Record with Same Key).
    I know that compounding InfoObjects (since i need to pull duplicate records from table as one candidate can have many institute & employer but they will always be referred by same OBJID) is one of the way but how to manage data through compounding coming from 2 tables.
    Also i donot want to create new objects as it will effect whole of the setup.
    Is there any other way.
    Can anyone give idea as to how to get records in BW.
    Thanks in advance.

    Hi Sundar,
    Thanks for your help. I wen tthrough the two discussions and found the following:
    1. I cannot include the primary/unique keys in the selection as it would make everything distinct. This restricts me from pointing me to the exact record that has changed.
    2. The columns would be dynamic. I want a config kind of solution where i can define the tables, columns on both the sides. And add/remove compare fields in the setup tables.
    Thanks,
    Faruq.

  • How to delete the duplicate records in a table without promary key

    I have a table that contains around 1 million records and there is no promary key or auto number coulums. I need to delete the duplicate records from this table. what is the simple effective way to do this.

    Please see this link:
    Remove duplicate records ...
    sqldevelop.wordpress.com

  • Counting duplicate records in a table

    Hi,
    I have to display duplicate records in a table,but the table name and column should be passed dynamically(In procedure). Please let me know the query for this.

    Try this one, is used to find the duplicate value from table
    Type: I
    SELECT * FROM employees e1 WHERE rowid> (SELECT min(rowid)
    FROM employees e2 WHERE e1.department_id=e2.department_id);
    Type: II
    SELECT * FROM my_table t1 WHERE EXISTS (SELECT 'x' FROM my_table t2
    WHERE t2.key_value1 = t1.key_value1
    AND t2.key_value2 = t1.key_value2
    AND t2.rowid > t1.rowid);
    Type: III
    SELECT count(*), empn FROM empmast_dum
    GROUP BY empn HAVING count(*) >1 ORDER BY empn;
    Type: IV
    SELECT dep, name,net,RANK() OVER (PARTITION BY dep ORDER BY net) rank
    FROM empmast_dump
    WHERE dep=04;
    Type: V
    SELECT empn FROM empmast_dump
    WHERE empn NOT IN(SELECT MIN(empn)
    FROM empmast_dump GROUP BY NAME;
    I have to display duplicate records in a
    table,but the table name and column should be passed
    dynamically(In procedure). Please let me know the
    query for this.When you need to pass table name dynamically in your procedure ,
    just enter table name as substitution variable or bind variable, if u want to know about
    this, read here
    venki
    http://venki-hb.blogspot.com/2008/02/basic-sql-query-tips.html

  • How to identify new records in a table using OBIEE

    Hi,
    I have price change table as and when a record comes into this table i have to generate an alert. Then show a report with the price changes on which i can invoke an action to go into my transactional system to make the chnage. And once the change is made the process again starts to look for any new price chnage records that are recieved.
    Could anyone pls tell me how to identify new records in a table.
    Rgds

    SELECT ID, LastName, FirstName,
    RANK() OVER (PARTITION BY LastName,
    FirstName ORDER BY ID) AS SeqNumber
    FROM
    (SELECT ID, LastName, FirstName
    FROM Customers
    WHERE (LastName, FirstName) IN
    (SELECT LastName, FirstName
    FROM Customers
    GROUP BY LastName, FirstName
    HAVING COUNT(*) > 1)

  • Duplicate records in a table

    i need to find duplicate records in a table that have the same name but a different id number.
    only fields i am using is the id, first name, last name, middle name
    any help would be great
    thanks

    Well, to just find the duplicate names, you can:
    select first_name, middle_name, last_name, count(*)
      from t
    group by first_name, middle_name, last_name
    having count(*) > 1;If you want to find the ids that are linked to these dupes, then:
    select *
      from t
    where (first_name, middle_name, last_name) in
       (select first_name, middle_name, last_name
          from t
         group by first_name, middle_name, last_name
        having count(*) > 1);

  • 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

  • Duplicate records in Fact Tables

    Hi,
    We are using BPC 7.0 MS SP7. BPC created duplicate records in WB and Fac2 tables. We faced similar issue before and the solution was to reboot the server and cleanup the additional data created. I think it should not be an issue with the script logic files we have. We had the issue across all applications. Data is fine now after the server reboot and running the same logic files.  I want to know if any one faced this issue and if there is any solution other than reboot. I appreciate your help.
    Thanks
    Raj

    Hi Sorin,
    I know this thread is rather old, but i have a problem which is pretty much related to this thread and appreciate if you could assist me. I have client running on 7.0 MS who has been using it for the past 3 years.
    It is a heavily customized system with many batch files running daily to update dimensions, copy data and sort. And Yes we do use custom packages that incorporates stored procedures.
    Recently, with no change in environment, we encountered our factwb ballooning up out of no where. fact table only contains less then 1 gb data but, factwb has 200 gb data and practically paralayzed the system. There is also equilavent 300 gb increase in the log files.
    We are not able to find out what caused this? Or if even the 200gb records in wb are even valid records that are duplicated. Is there a way to troubleshoot this?

  • To find the duplicate record in internal table

    Hi,
    i have a requirement to fine the duplicate record with 3 fields.
    i am getting a flat file with 15 fields  .
    i need to check the duplaicate records of  3 fields . if i get any 2nd same record of 3 fields , the records will go to other internal table.
    for ex :
    1. aaa  bbb ccc ddd  eee  fff  ggg   hhh
    2. aaa  bbb ccf  dde edd  ffg ggh   hhj
    3. aaa  bbb cce ddd  ees ffh  ggu  hhk
    in that 1st record and 3rd record are same (aaa bbb ddd)
    i need to find 3rd record
    please help me
    regrards
    srinivasu

    hi,
    itab2[] = itab1[].
    sort itab1 by f1 f2 f3.
    sort itab2 by f1 f2 f3.
    delete itab2 index 1.   "to delete the first record in itab2.
    loop at itab1 into ws_itab1.
      loop at itab2 into ws_itab2.
       if ws_itab1-f1 = ws_itab2-f1 and
         ws_itab1-f2 = ws_itab2-f2 and
        ws_itab1-f3 = ws_itab2-f3.
         ws_itab3 = ws_itab2.
         append ws_itab3 into itab3.   "Third internal table.
       endif.
    endloop.
    delete itab2 index 1.   
    endloop.
    ITAB3 will have all the duplicate records.
    Regards,
    Subramanian

  • Duplicate records in Internal table

    Hi All,
    I want to find out the duplicate entry in the internal table. I have used,
    Delete Adjacent duplicates from itab.
    It is straight away deleting the record.
    I want the user to correct that duplicate record.
    May be some error message.
    I have tried, with read,
    Read table itab with key bzirk = itab-bzirk vkorg = itab-vkorg kunnr = itab-kunnr
    matnr = itab-matnr comparing bzirk vkorg kunnr matnr.
    But it's giving sy-subrc = 0 for the first record also.
    Even, I have tried like, but it's giving syntax error.
    Loop at itab where bzirk = itab-bzirk vkorg = itab-vkorg kunnr = itab-kunnr
    matnr = itab-matnr.
    Endloop.
    Any method in case on Table control entries.
    Thanks & Regards,
    Kalyan Chandramouli
    SAP Consultant

    Hi,
    Create a new internal table and assign the all the records of itab1 to itab2.
    1.Sort Itab2.
    2.delete adjacent duplicates.
    3. loop at itab2.
         loop at itab1 where <conditon you want....>
         count = count + 1.
         endloop.
          if count GT 1.
            append the iatb2 records for user correction....
          endif.
       endloop.
    If the hint is useful… Say thanks by reward….
    Regards,
    Prabhu Rajesh

  • Importing and Updating Non-Duplicate Records from 2 Tables

    I need some help with the code to import data from one table
    into another if it is not a duplicate or if a record has changed.
    I have 2 tables, Members and NetNews. I want to check NetNews
    and import non-duplicate records from Members into NetNews and
    update an email address in NetNews if it has changed in Members. I
    figured it could be as simple as checking Members.MembersNumber and
    Members.Email against the existance of NetNews.Email and
    Members.MemberNumber and if a record in NetNews does not exist,
    create it and if the email address in Members.email has changed,
    update it in NetNews.Email.
    Here is what I have from all of the suggestions received from
    another category last year. It is not complete, but I am stuck on
    the solution. Can someone please help me get this code working?
    Thanks!
    <cfquery datasource="#application.dsrepl#"
    name="qryMember">
    SELECT distinct Email,FirstName,LastName,MemberNumber
    FROM members
    WHERE memberstanding <= 2 AND email IS NOT NULL AND email
    <> ' '
    </cfquery>
    <cfquery datasource="#application.ds#"
    name="newsMember">
    SELECT distinct MemberNumber
    FROM NetNews
    </cfquery>
    <cfif
    not(listfindnocase(valuelist(newsMember.MemberNumber),qryMember.MemberNumber)
    AND isnumeric(qryMember.MemberNumber))>
    insert into NetNews (Email_address, First_Name, Last_Name,
    MemberNumber)
    values ('#trim(qryMember.Email)#',
    '#trim(qryMember.FirstName)#', '#trim(qryMember.LastName)#', '#
    trim(qryMember.MemberNumber)#')-
    </cfif>
    </cfloop>
    </cfquery>
    ------------------

    Dan,
    My DBA doesn't have the experience to help with a VIEW. Did I
    mention that these are 2 separate databases on different servers?
    This project is over a year old now and it really needs to get
    finished so I thought the import would be the easiest way to go.
    Thanks to your help, it is almost working.
    I added some additional code to check for a changed email
    address and update the NetNews database. It runs without error, but
    I don't have a way to test it right now. Can you please look at the
    code and see if it looks OK?
    I am also still getting an error on line 10 after the routine
    runs. The line that has this code: "and membernumber not in
    (<cfqueryparam list="yes"
    value="#valuelist(newsmember.membernumber)#
    cfsqltype="cf_sql_integer">)" even with the cfif that Phil
    suggested.
    <cfquery datasource="#application.ds#"
    name="newsMember">
    SELECT distinct MemberNumber, Email_Address
    FROM NetNewsTest
    </cfquery>
    <cfquery datasource="#application.dsrepl#"
    name="qryMember">
    SELECT distinct Email,FirstName,LastName,MemberNumber
    FROM members
    WHERE memberstanding <= 2 AND email IS NOT NULL AND email
    <> ' '
    and membernumber not in (<cfqueryparam list="yes"
    value="#valuelist(newsmember.membernumber)#"
    cfsqltype="cf_sql_integer">)
    </cfquery>
    <CFIF qryMember.recordcount NEQ 0>
    <cfloop query ="qryMember">
    <cfquery datasource="#application.ds#"
    name="newsMember">
    insert into NetNewsTest (Email_address, First_Name,
    Last_Name, MemberNumber)
    values ('#trim(qryMember.Email)#',
    '#trim(qryMember.FirstName)#', '#trim(qryMember.LastName)#', '#
    trim(qryMember.MemberNumber)#')
    </cfquery>
    </cfloop>
    </cfif>
    <cfquery datasource="#application.dsrepl#"
    name="qryEmail">
    SELECT distinct Email
    FROM members
    WHERE memberstanding <= 2 AND email IS NOT NULL AND email
    <> ' '
    and qryMember.email NEQ newsMember.email
    </cfquery>
    <CFIF qryEmail.recordcount NEQ 0>
    <cfloop query ="qryEmail">
    <cfquery datasource="#application.ds#"
    name="newsMember">
    update NetNewsTest (Email_address)
    values ('#trim(qryMember.Email)#')
    where email_address = #qryEmail.email#
    </cfquery>
    </cfloop>
    </cfif>
    Thank you again for the help.

  • Identify Duplicate Records

    Post Author: chrise
    CA Forum: Crystal Reports
    I know that Crystal has the ability to identify all distinct records, thereby, getting rid of all duplicate records. However, I need to do the exact opposite and so far have been unsuccessful. Can anyone aid me in creating a report to identify only duplicate records in Crystal?
    Thanks.

    Post Author: SKodidine
    CA Forum: Crystal Reports
    Check out this KBase article.
    Retrieving duplicate records

  • How can I view duplicate records in a table?

    Hello everyone,
    My question is very straight forward. How can I view all duplicate records?
    Thanks in advance,
    Sonya

    Easy enough,
    select t1.n1,t1.c1,count(*) as "TOTAL_DUPS" from tableA t1 having count(*) > 1 group by t1.n1,t1.c1 order by count(*) desc
    Tyler

  • To delete duplicate records from internal table

    hi friends,
    i have to delete records from internal table based on following criterion.
    total fields are 7.
    out of which  if 4 fields are same and 5th field is different,then both records must be deleted.
    in case all five fields are same,the program should do nothing.
    for example.
    if there are 3 records as follows
    a1 b1 c1 d1 e1 f g
    a1 b1 c1 d1 e2 w r
    a1 b1 c1 d1 e1 j l
    then first two records should be deleted as four fields are same but fifth(e) field differs.
    but third record should remain as it is evenif first five fields are same for first and third record.
    values of last two fields need not to be consider for deleting the records.

    LOOP AT ITAB.
      V_FILED5 = ITAB-F5. "to compare later
      V_TABIX = SY-TABIX. "used to delete if condition not matches
      READ TABLE ITAB WITH KEY F1 = ITAB-F1
                               F2 = ITAB-F2
                               F3 = ITAB-F3
                               F4 = ITAB-F4.
      IF SY-SUBRC = 0.
        IF ITAB-F5 <> V_FIELD5.
    *--both the records to be deleted,as Field5 is different.
          DELETE ITAB INDEX SY-TABIX. "deletes that record
          DELETE ITAB INDEX V_TABIX. "deletes the current record
        ENDIF.
      ENDIF.
    ENDLOOP.
    Message was edited by: Srikanth Kidambi
    added comments
    Message was edited by: Srikanth Kidambi

Maybe you are looking for

  • Will Laserjet 5 work with windows 7.

    I GOT A DESKTOP RUNNING WINDOWS 7 HOME PREMIUM 64 BIT. HAS 6 USB PORTS NO PARALLEL PRINTER PORT. WILL THIS HP LASERJET 5 WORK WITH WINDOWS 7? THANKS I WOULD NEED TO INSTALL A IEEE 1284 PARALLEL CARD. This question was solved. View Solution.

  • I'm having trouble finding twisted-web

    I am running x86_64 and trying to install the twisted-web package and I am having some trouble finding it. I used the package search on the archlinux.org main page and I found a  match, but when I try pacman -Sy twisted-web I get "error: 'twisted-web

  • I upgraded to 3 gig of ram and now my machine doesn't work

    Hi all I have just switched out my 2 x 512 mb chips and up'ed my ram to 3 gig. The only problm is that with 3 gig in the machine it wont boot up. I have tries both the 1 gig and the 2 gig chips by themselves and have had no problems. but with both of

  • Address Book Synchronizer not working

    Hi Im running CM 4.2 and the address book synch dosent work i exported all my contacts to my WAB and its giving me a password error saying unable to login with the configured password. im using the same UN and PW that i use on the CCM user page. Any

  • Set up table data extracted from R/3 not visible in data target of BW

    Hai friends,          I am currently working on extracting data from R/3 to BW. I read the several docs given in the forum and did the following:   1) In the LBWE transaction, my extract structure is already active.   2) In SBIW, i went to the fillin