Join creation between 2 tables while duplicate records exist

Hi all ,
I have following 2 tables. I need to join both table on SAM_CUST_ID col in ABC (detail table) and DE_CUST_DI (UK) in XYZ (master table). But both columns contain duplicate values of customer because we load these table from anther database.Is there any solution that how can i join these tables by using DE_CUST_ID and SAM_CUST_ID.If I create Enable Novalidate constraint on these columns thery are working ??? Any suggestion would be highly appriciated.
Regards
REM TEST XYZ
  CREATE TABLE "TEST"."XYZ"
   (     "DE_BANK_ID" VARCHAR2(255 BYTE),
     "DE_CUST_ID" NUMBER(*,0),
     "XYZ_NO" NUMBER(*,0),
     "DE_HOLD_OUTPUT" VARCHAR2(255 BYTE),
     "DE_SHORT_NAME" VARCHAR2(255 BYTE),
     "DE_NAME1" VARCHAR2(255 BYTE),
     "DE_NAME2" VARCHAR2(255 BYTE),
     "DE_STREET_ADDR" VARCHAR2(255 BYTE),
     "DE_TOWN_COUNTRY" VARCHAR2(255 BYTE),
     "DE_POST_CODE" NUMBER(*,0),
     "DE_COUNTRY" VARCHAR2(255 BYTE),
     "DE_COPIES" NUMBER(*,0),
     "DE_EMAIL" VARCHAR2(255 BYTE),
     "DE_LOCAL_A1" VARCHAR2(255 BYTE),
     "DE_LOCAL_A2" VARCHAR2(255 BYTE),
     "DE_LOCAL_A3" VARCHAR2(255 BYTE),
     "DE_LOCAL_N1" FLOAT(126),
     "DE_LOCAL_N2" FLOAT(126),
     "DE_LOCAL_N3" FLOAT(126),
      CONSTRAINT "XYZ_UNIQUE" UNIQUE ("DE_CUST_ID", "XYZ_NO") ENABLE
REM TEST XYZ_IDX1
  CREATE UNIQUE INDEX "WH1"."XYZ_IDX1" ON "WH1"."XYZ" ("DE_CUST_ID", "XYZ_NO")
REM TEST ABC
  CREATE TABLE "TEST"."ABC"
   (     "ABC_BANK_ID" VARCHAR2(255 BYTE),
     "ABC_CUST_ID" NUMBER(22,0),
     "ABC_ABC_ID" VARCHAR2(255 BYTE),
     "ABC_PORT_NAME" VARCHAR2(255 BYTE),
     "ABC_CCY" VARCHAR2(255 BYTE),
     "ABC_INDICATOR" NUMBER(*,0),
     "ABC_MANAGED_ACCOUNT" VARCHAR2(255 BYTE),
     "ABC_CLOSED_DATE" DATE,
     "ABC_INVESTMENT_PGM" VARCHAR2(255 BYTE),
     "ABC_ACC_OFF" NUMBER(*,0),
     "ABC_FREQUENCY" VARCHAR2(255 BYTE),
      CONSTRAINT "ABC_UNIQUE" UNIQUE ("ABC_ABC_ID") ENABLE,
      CONSTRAINT "ABC_DE_ADD_CUSID_FK" FOREIGN KEY ("ABC_CUST_ID")
       REFERENCES "WH1"."DE_ADDR" ("DE_CUST_ID") ENABLE NOVALIDATE
REM WH1 ABC_UNIQUE
  CREATE UNIQUE INDEX "WH1"."ABC_UNIQUE" ON "WH1"."ABC" ("ABC_ABC_ID")
 

would u like to explain by an example?First of all why not removing duplicates
If you need to keep duplicates, you entire design looks wrong.
You have to follow normalization rules and always have LPK (logical primary key) and PK for transactional tables
An example is simple
A1 and B2 duplicates
After data is loaded it should look like this
Table 1
id val
1 A1
2 A1
3 B2
4 B2
Table 2
id val
1 A1
2 A1
3 B2
4 B2--
(id - unique sequence)
Of cause there is more possibility but
nobody can tell you how to do this (or what to do) based on what you showed.
Good luck

Similar Messages

  • Fact Table allows duplicate records

    Is Fact Table allows duplicate records?

    What do you mean by duplicate records? It could be what appears duplicate to you is having some other technical key info that are different in the fact table.
    At technical level, there wouldn't be duplicate records in fact table [in SAP's BW/BI there are two fact tables for each cube - which can itself cause some confusion]

  • Join Condition between tables

    Hi all,
    Is it possible to propose a join condition (using SQ02) between two fields of two tables other than what is proposed by the system?
    Thanks
    Sandeep

    Hi Sandeep,
          You can very much match other fields of two tables in SQ02.
      1. Goto SQ02
      2. Give the infoset name
      3. Goto change mode
      4. Press the Join button, it will display the join conditions between the two tables.
      5. Press Join Conditions, it will propose the system generated join conditions
          with key fields
      6. If you want to match your own fields other than the key fields you can just 
          point the mouse pointer on the field of the first table and just drag it to the field
          of the second table. It will create a join condition.
      7. Save the infoset.
      Regards,
        Jayaram...

  • Duplicate records exists in same request of a PSA

    Dear SAP Professionals,
    Please look into below issue I am facing.
    1) I have only 1 request (green) in PSA.
    2) When I am looking into that request, I found there are 4 Packages.
    3) In Package 3 & 4, I found the same records has been extracted twice.
    Here I am not able to understand, why this is happening?
    I tried to run the extractor in R/3 side, and found only 7 records exist for that particular condition.
    But when I look into PSA Maintenance screen, there are 14 records exist for the same condition (7 records of Pkg 3 + 7 records of Pkg 4).
    Request you to provide the necessary guidance.
    Many thanks in advance.
    Best Regards,
    Ankur Goyal

    Hello Ankur,
    You didn't mention whether you are loading master data or transaction data.
      If you are loading Master data so it will not create any problem, because it will be overwrite. It will load  Package  3 firstly then data of Package  4 will be overwrite with Package 3. So there will be only 7 records in data target .
        But if you are loading  Transaction data  so  pick the data once again from the R/3 and check  and for  this  you have to delete previous request.
    Thanks
    Abha
    Edited by: Abha Sahu on Jan 29, 2010 3:50 PM

  • Relationship between tables while using inner joins.

    Hi,
    I had a few clarifications on "inner joins", and as i was going through the forum, i came across two points,
    1. In one of the threads it said " inner joins is applicable for tables that have a parent child relationship.
    2. In another thread it said " inner join is established from master table (the table on the left) to the transcation table (the table on the right)".
    I have two clarifications based on the above points.
    1. Is it necessary that the tables on which im performing an inner join should have a parent-child/children relationship or is it enough that the tables just have a common field.
    2.  Also is it necessary that the master table should come first, (or can i use any child table from where i can fetch the records when there is a mater table in my report) as shown below.
    Eg: select * <fields> from <master table> inner join <table> on <field> into <itab>.
    Edited by: Narayananchandran on Dec 27, 2010 12:31 PM

    have two clarifications based on the above points.
    1. Is it necessary that the tables on which im performing an inner join should have a parent-child/children relationship or is it enough that the tables just have a common field.
    2. Also is it necessary that the master table should come first, (or can i use any child table from where i can fetch the records when there is a mater table in my report) as shown below.
    Eg: select * <fields> from <master table> inner join <table> on <field> into <itab>
    1) NO
                      2) NO

  • Using JOIN to two tables to find records NOT in second table...

    I always seem to get these types of queries wrong and need a bit of help:
    I have a table of relationships called MARKETER_ACCOUNT and another table of pending relationships called ACCOUNT_ENROLLMENT.
    I have accounts that can be enrolled with a MARKETER. They enter the ACCOUNT_ENROLLMENT table as Pending and on a certain Effective Date the go active and then move to the MARKETER_ACCOUNT table. If a relationship ends, it can end by either enrolling with another Marketer or if no pending enrollment they are assumed to be going back to the parent company.
    So I want to find all the records that came back to the parent company (i.e. they should not have a pending record in the ACCOUNT_ENROLLMENT table but have an end date in the MARKETER_ACCOUNT table:
    Select * from MARKETER_ACCOUNT M
    where M.account_no NOT IN (select E.account_no from ACCOUNT_ENROLLMENT E
    where E.effective_date between '08-DEC-2009' and '07-JAN-2010')
    and M.expiration_date between '08-DEC-2009' and '07-JAN-2010';
    This query is still running and I'm not sure where I am going wrong. I want to say GIVE me all the accounts in the MARKETER_ACCOUNT table that have an expiration date between '12/07/2009' and '01/07/2010' and where those accounts are NOT pending in the ACCOUNT_ENROLLMENT table where the effective date is for the same period.
    Any help would be greatly appreciated.
    Sean

    You could possibly try the NOT EXISTS version of the query:
    SELECT  *
    FROM    MARKETER_ACCOUNT M
    WHERE   NOT EXISTS
                    SELECT  NULL
                    FROM    ACCOUNT_ENROLLMENT E
                    WHERE   M.ACCOUNT_NO = E.ACCOUNT_NO
                    AND     E.EFFECTIVE_DATE BETWEEN TO_DATE('08-DEC-2009','DD-MON-YYYY') AND TO_DATE('07-JAN-2010','DD-MON-YYYY')
    AND     M.EXPIRATION_DATE BETWEEN TO_DATE('08-DEC-2009','DD-MON-YYYY') AND TO_DATE('07-JAN-2010','DD-MON-YYYY');Otherwise check out these threads:
    {message:id=1812597}
    {thread:id=863295}

  • How can I join 3 tables while extracting data from SAP R/3?

    I have 3 tables with the following columns
    Emp table (emp)
      emp_id
      emp_name
      emp_add
    Dept table (dept)
      dept_id
      dept_name
      dept_loc
    Location table (loc)
      loc_id
      loc_name
    Now. If I want to select data from loc_id = 10 and emp_id between 2000 and 3000
    How to join these three tables while extracting data from R/3
      join condition
       loc.loc_id = dept.loc_id
    and dept.dept_id = emp.dept_id
    and loc.loc_id =10
    and emp.emp_id between 2000 and 3000.
    Could any one let me know the procedure to extract this data into BW system.

    Hi,
    shouldn't your join condition be:
    loc.loc_id = dept.DEPT_LOC
    and dept.dept_id = ??
    If you can join the three tables then create a generic datasource (RSO) based on a view (create your view with your join in SE11).
    Enable the loc_id and the emp_id as selectable in the datasource so you can then select the values from a BW IPack.
    hope this helps...
    Olivier.

  • Duplicate record with same primary key in Fact table

    Hi all,
       Can the fact table have duplicate record with same primary key . When i checked a cube i could see records with same primary key combination but the key figure values are different. My cube has 6 dimentions (Including Time,Unit and DP) and 2 key figures. So 6 fields combined to form the composite primary key of the fact table. When i checked the records in se16 i could see duplicate records with same primary key. Ther are no parallel loading happening for the cube.
    BW system version is 3.1
    Data base is : Oracle 10.2
    I am not sure how is this possible.
    Regards,
    PM

    Hi Krish,
       I checked the datapacket dimention also. Both the record have same dimention id (141). Except the Keyfigure value there is no other change in the Fact table record.  I know this is against the basic DBMS primary key rule. But i have records like this in the cube.
    Can this situation arise when same records is there in different data packet of same request.
    Thx,
    PM
    null

  • Duplicate records in SQ00 query

    HI,
    I am trying to make a query joining 3 tables. All tables have atleast 1 key field in common. In the output I have all fields from the main table, 3 fields from table "B" with a left outer join and 1 field from table "C" with an inner join. I am recieving duplicate records in the output. Is this issue a result of incorrect join conditions or is something else needed. Below is an illustration of join conditions.
    I look forward to your responses
    Regards,
    Curt

    Curt - is this related to BI?
    SQ00 is an ECC transaction and you may have better luck posting in one of the ERP spaces

  • Error RSMPTEXTS~:Duplicate record dur durin EHP5 in phase SHADOW_IMPORT_INC

    Hi expert,
    i find this error during an EHP5 upgrade in phase shadow_import_inc:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    SHADOW IMPORT ERRORS and RETURN CODE in SAPK-701DOINSAPBASIS.ERD
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    2EETW000 Table RSMPTEXTS~: Duplicate record during array insert occured.
    2EETW000 Table RSMPTEXTS~: Duplicate record during array insert occured.
    1 ETP111 exit code           : "8"
    here also the last part of log SAPK-701DOINSAPBASIS.ERD
    4 ETW000 Totally 4 tabentries imported.
    4 ETW000 953984 bytes modified in database.
    4 ETW000  [     dev trc,00000]  Thu Aug 11 16:58:45 2011                                             7954092  8.712985
    4 ETW000  [     dev trc,00000]  Disconnecting from ALL connections:                                       28  8.713013
    4 ETW000  [     dev trc,00000]  Disconnecting from connection 0 ...                                       38  8.713051
    4 ETW000  [     dev trc,00000]  Closing user session (con=0, svc=0000000005C317C8, usr=0000000005C409A0)
    4 ETW000                                                                                8382  8.721433
    4 ETW000  [     dev trc,00000]  Detaching from DB Server (con=0,svchp=0000000005C317C8,srvhp=0000000005C32048)
    4 ETW000                                                                                7275  8.728708
    4 ETW000  [     dev trc,00000]  Now I'm disconnected from ORACLE                                        8648  8.737356
    4 ETW000  [     dev trc,00000]  Disconnected from connection 0                                            84  8.737440
    4 ETW000  [     dev trc,00000]  statistics db_con_commit (com_total=13, com_tx=13)                        18  8.737458
    4 ETW000  [     dev trc,00000]  statistics db_con_rollback (roll_total=0, roll_tx=0)                      14  8.737472
    4 ETW000 Disconnected from database.
    4 ETW000 End of Transport (0008).
    4 ETW000 date&time: 11.08.2011 - 16:58:45
    4 ETW000 1 warning occured.
    4 ETW000 1 error occured.
    1 ETP187 R3TRANS SHADOW IMPORT
    1 ETP110 end date and time   : "20110811165845"
    1 ETP111 exit code           : "8"
    1 ETP199 ######################################
    4 EPU202XEND OF SECTION BEING ANALYZED IN PHASE SHADOW_IMPORT_INC
    and i've already try to use the last version of R3trans.
    can you help me????
    thanks a lot
    Franci

    Hello Fransesca,
    I am also facing same error while upgrading ehp5 upgradation please if you know tell me steps to solve it.
    Thanks,
    Venkat

  • Multi-Record (NON-DB) block - duplicate records

    I have a non-db block called 'EDITOR_INFO' that captures all the editor's information. The block has the following fields in it: editor_name,editor_type,address_lines1 thru4, city, state, zip, taxid_ssn_type,taxid_ssn.
    I need to check to make sure that the user is not entering the duplicate editors. How can I adapt the infamous Kevin Clarke's solution to this (if at all)? What would be my datablock, control block etc?
    Can any one pls. provide any guidance.
    Thanks,
    Chiru
    Edited by: Megastar_Chiru on Nov 8, 2010 3:55 PM
    Edited by: Megastar_Chiru on Nov 8, 2010 3:56 PM

    Chiru, if all you need is to add/query records in a block, you should consider making a data-block instead of control-block. And use POST to post the data into table which will let you check against the table if a record exists or not.
    But if you want to have it done using a control-block then follow below sample steps.
    In WHEN-VALIDATE-RECORD of your control block, you can check if entered record is already in the table or not.
    If it exists, then raise error message and stop until user corrects the data... if it does not exist, then INSERT into the table.
    For this scenario, I created a small table with two columns.
    CREATE TABLE TABLE_A (Col1 NUMBER, Col2 VARCHAR2(30));Now I created a form with a control block (BLOCK2). It has 10 records with vertical layout and two control-items on it (TEXT_ITEM4 and TEXT_ITEM5). And below is code used on WHEN-VALIDATE-RECORD.
    -- WHEN-VALIDATE-RECORD
    DECLARE
      temp VARCHAR2(1);
      CURSOR c_check_existance IS
      SELECT 'X'
        FROM table_a
       WHERE col1 = :BLOCK2.text_item4;
    BEGIN
        :GLOBAL.Valid_Records := 'N';
         IF :block2.text_item4 IS NOT NULL THEN          
              OPEN c_check_existance;
              FETCH c_check_existance INTO temp;
              IF c_check_existance%FOUND THEN
                   CLOSE c_check_existance;
                                                    :GLOBAL.Valid_Records := 'N';
                   MESSAGE('Record already exists in table');
                   RAISE FORM_TRIGGER_FAILURE;
              ELSE
                   INSERT INTO table_a (col1, col2)
                                VALUES (:block2.text_item4, :block2.text_item5);
                                                    :GLOBAL.Valid_Records := 'Y';
              END IF;
              CLOSE c_check_existance;
         END IF;
    END;Remember, when making a control block like a data block, you have to code everything yourself.

  • Help with clean up duplicate records

    One of my tables have duplicate records in paris that needs to be cleaned up. I want to cleanup the earlier TIMESTAMP.
    ID MODIF_TIME_STAMP
    483070 1/7/2005 11:49
    483070 1/13/2005 17:19
    483071 1/6/2005 11:49
    483071 1/14/2005 17:19
    483072 1/15/2005 11:49
    483072 1/07/2005 17:19
    9000 records
    What is the easiest way to pick only the ID of the earlier timestamp of each pair.
    Thanks in advance.
    Ittichai

    Hallo,
    delete from your_tab
    where rowid in
    (select rowid from
    (select rowid, id, modif_time_stamp, row_number() over (partition by id order by modif_time_stamp desc) rn from your_tab)
    where rn > 1
    )This query deletes records with earlier date for every id
    Regards
    Dmytro
    Message was edited by:
    Dmytro Dekhtyaryuk

  • Error due to duplicate records

    Hello friends,
    I have done a full upload to the particular charactersitics info object using direct update.(PSA and directly to data target). I used PSA and Subsequently into data target option.
    When i load the data into the object through process chain i get an error that duplicate records exist and the request become red in PSA.
    But no duplicate records exist in the data package and when we try to manually load the record from PSA to data Target it works fine.
    Can any one try to throw some lights on this error?
    Regards
    Sre....

    Hello Roberto and Paolo
    There was an OSS note that we should not use that option only PSA with delete duplicate records and update into data target .
    I dont know the reason Exactly.
    Can you throw some lights on this, Why its like that?
    Thanks for the reply paolo and roberto
    Regards
    Sri

  • 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.

  • How to tune the query for duplicate records while joining the two tables

    hi,i am executing the query which has retrieving multiple tables,in which one of them has duplicate record,how to get single record

    Not enough info...subject says "tune" the query, message says "write" the query...and where is actual query that you had tried ?

Maybe you are looking for

  • How to retreive data from disabled iPhone 4

    Hi. I have permanently disabled iPhone 4. it is my wife`s phone who passed away. i need to get photos and videos from the phone. The original computer which i  synced it with doesn't help. I have 2 computer and don't remember which one was that i syn

  • Wish list for the iPhone and iPad

    I would add the following to the OS for iPhones and iPads which would allow the user to have control over multitasking applications. This will overall save battery life. 1. Create a setting feature to enable/disable multitasking for each application.

  • MP Navigator crashing upon quit

    Whenever I quit MP navigator from scanning with my Canon printer I get a crash message looking like this: Process: MP Navigator EX 2.0 [175] Path: /Applications/Canon Utilities/MP Navigator EX 2.0.app/Contents/MacOS/MP Navigator EX 2.0 Identifier: jp

  • FindGroupMembers operation

    When invoking the findGroupMembers operation in the user lookup service group, I am getting an error transaction is not active.  The input I have given is a group object that is already existing in the user manager. Has any body tried using this serv

  • Backing Up iTunes Library to Disc

    i recently tried backing up my Entire iTunes Library to disc, but i left the computer and it went to Sleep during the backup process, and the disc was ejected. now each time i try to backup, i get an error message saying the "burning was unsuccessful