SAP Query - Need to join 3 Tables via outer join

Hi,
I need to join 3 Tables using SAP Query. I wish an OUTER JOIN to be performed for the table join.
For Example:
Table 1 has 1000 Entries           Field A             Field B          
Table 2 has 300 Entries             Field A            Field C
Table 3 has 100 Entries             Field A           Field D
The normal Join (INNER JOIN) gives me only the records that exists in all the 3 Tables.
But what i need is:
In the above example, If one entry in Table 1 has no matching records in Table 2 / Table 3, there should be an output entry in the SAP Query like
Field A            Field B              Field C            Field  D
xxxx              yyyy                  Blank             Blank
If there is a common record that exists in the tables, that record should appear in the same entry in the Query output.
Field A            Field B              Field C            Field  D
xxxx              yyyy                  zzzz              aaaa
In this way, there should be a minimum of 1000 entries (Largest no of records in the Tables joined). More than 1000 records in the Query output depends on the number of common records.
Kindly help if you have come across such a scenario.
thanks & regds
sriram

Hi
Please join the outer join as below
Table1 with Field A  to Table 2 Field A-----outer join
Table1 with Field A  to Table 3 Field A------outer join
then you get the out put as per your requirement
Regards
Damu

Similar Messages

  • OJ syntax for multi-table left outer join with MS Oracle Driver

    I have a multi-table left outer join that works fine in SQL Server ODBC Driver, Oracle ODBC driver 8.01.07.00, but not with Microsoft ODBC Driver for Oracle 2.573.7326.0
    SELECT * from { oj A LEFT OUTER JOIN B ON A.col1 = B.col1 LEFT OUTER JOIN C ON A.col1 = C.col1 }
    I noticed someone had a similar problem (the proposed solution doesn't work):
    http://www.justpbinfo.com/listarchive/msg02874.html
    Does anyone know how to get this working with the Microsoft ODBC Driver for Oracle? Or does it just not work?

    The Microsoft ODBC Driver for Oracle 2.573.7326.0 does perform the same 'fix up' with {oj} in Oracle 8i. The problem is that it doesn't work when joining more than two tables:
    This works:
    SELECT * from { oj A LEFT OUTER JOIN B ON A.col1 = B.col1}
    This doesn't work:
    SELECT * from { oj A LEFT OUTER JOIN B ON A.col1 = B.col1 LEFT OUTER JOIN C ON B.col1 = C.col1 }
    (The second query will work with the Oracle Oracle ODBC driver, with a bit of tweaking. But I haven't found a way to get it to work with the Microsoft ODBC Driver for Oracle 2.573.7326.0. My suspicion is that it just doesn't work.)
    Gavin

  • Join columns of outer join with table have no uniqueness cons

    Hi! I'm getting noizy error in alert log from time to time:
    Join columns of outer join with table <table_name> have no uniqueness constraints
    I've collected all the queries (v$sql, all_source) with montioned table, but non of them produces that error if executed.
    Any hints how to reproduce this error or where else to search that buggy sql join?
    Edited by: user545083 on 25.10.2010 6:21

    Hi
    I think this error is output via an materialized view refresh - check for mviews against the given table which fulfil the issue given in the error text.
    Thanks
    Paul

  • How to find Inner join or (Left)outer join for Infoset

    Dear Experts,
    We have one Infoset which is based on the Master data and DSO. It is linked 0BPARTNER field From the Master Data and SOLD TO PARTY field from the DSO.
    Here Could you please suggest me how can we able to find that whether this Infoset is based on Inner Join or (Left) outer join.
    Thanks and Regards,
    Suresh.

    HI Suresh,
    If the infoset is based on left outer join , you see the respective table shaded in a dirrerent colour and also displays
    that it is a left outer join in the connection
    refer the below link for the details on left outer join , you can make a join as left outer from the context menu of the
    object required
    http://help.sap.com/erp2005_ehp_04/helpdata/EN/21/af0942b9dc9c39e10000000a155106/frameset.htm
    Regards,
    Sathya

  • How to Mark join as left outer join in Info set

    Hi Folks,
    I have 2 info cubes in Info set, I need to mark the join as Left outer join.
    I have read some blogs where is says that it cant be joined, but one of my colleagues has made left outer join using two cubes.
    I want to replicate the same thing into my design.
    If i normally connect one IO to another cubes same IO- its a normal join- its not written as left outer join. I want to see left outer join written on my link.
    I tried global setting but no use.
    Am I missing some setting,

    Hi Vivek,
    Please have a look at SAP Note 577953 - @0S@ InfoSets (BW): Left outer joins.
    The answer on question "3. How do I define a left outer join in InfoSet maintenance?" describes how you should proceed.
    Best regards,
    Sander

  • Could any one tell me how to do the left outer join or right outer join?

    Could any one  tell me how to do the left outer join or right outer join in Webi Rich Client? thanks.

    we can do it in two ways
    1.  In  web intelligence level  on the query panel click the sql query and write the statement what ever u want there by modifying the existing statement.
    2.  In universe level select the fields in the two tables that you want to make join and create the join between two tables directly by joining field in table 1 to the field in the table 2 by drawing a line and double click on the line to view the join properties,then on join properties if we check the table 1 outer then it is left outer join if we check on table 2 outer then it will be the right outer join.after exporting the universe to the central sever we are now ready to use in web intelligence with out being changed anything in the sql query.
    endorse me if it is useful.
    thanks & regards
    Sreekanth.

  • How to use common object from two tables with out join.

    HI,
    I have two tables called A & B In A table i have the following objects
    1.weekend
    2.S1(measure)
    3.S2(measure)
    4.S3(measure)
    5.S4(measure)
    And In B table i have followning columns
    1.week end
    2.p1(measure)
    3.p2(measure)
    4.p3(measure)
    5.p4(measure)
    Now in universe i created all the measure objects i.e.s1,s2,s3,s4,p1,p2,p3,p4 A.weekend,B.weekend.
    instead of using week end two times i wnt to use only once because this is common in both table.
    if i use join between these tables i am getting values fine
    But With out join is there any thing to do in universe level to create common objects to use from both the tables..I tried using aggregate awareness but while reporting it is taking as two SQL.which is not synchronized.
    Please help me on this ...

    hi,
    Although  Weekend column is present in both tables, by creating a single Object in Universe, Universe can identify relationship with only table referenced in Object Creation.
    So, there will be no identification of relationship with other table measures.
    Obviously, you need to create 2 Weekend objects in Universe (in two classes).
    Case 1: You need not join these two tables in Universe. When you create 2 Queries in WEBI, automatcially Weekend objects are synchronized (if both are of same datatype)
    Case 2: If you join these two tables in Universe, Obviously,
    your SQL may contain Weekend from Table1, measures from Table 2
    or
    your SQL may contain Weekend from Table2, measures from Table 1
    Finally, You need to create 2 objects in Universe. But your query may contain a single Object based on Case 2.
    Regards,
    Vamsee

  • Query 4 joined tables with internal joins to represent a complex hierarchy!

    I've got to refine/replace a query (Oracle 9i) that
    currently joins rows from four tables in a hierarchical
    fashion that I use to produce a listing like this:
    agency abc 1
    ....division def 1.1
    ........service ghi 1.1.1
    ........service jkl 1.1.2
    ............faq mno 1.1.2.1
    ............faq pqr 1.1.2.2
    ........service stu 1.1.3
    ....division vwx 1.2
    ........service yyy 1.2.1
    ............faq zzz 1.2.1.1
    The change involves allowing for unlimited levels of
    nested child divisions to produce a listing like this:
    agency abc 1
    ....division def 1.1
    ........service ghi 1.1.1
    ........service jkl 1.1.2
    ............faq mno 1.1.2.1
    ............faq pqr 1.1.2.2
    ........service stu 1.1.3
    ....division vwx 1.2
    ........division xxx 1.2.1
    ............division aaa 1.2.1.1
    ............division bbb 1.2.1.2
    ................service aaa 1.2.1.2.1
    ....................faq fff 1.2.1.2.1.1
    ....................faq ggg 1.2.1.2.1.2
    ........service yyy 1.2.1
    ............faq zzz 1.2.1.1
    Notice the insertion of three nested divisions under
    division 1.2 with services and faqs under those. The
    order of names throughout is alphabetic within a nesting
    level.
    Here's the SQL I currently use, without nested divisions
    (it contains extra info that I use to control what and
    how names are displayed):
    SELECT
    agency.agency_id AGENCY_ID,
    agency.agency_type_id AGENCY_TYPE_ID,
    agency.name AGENCY_NAME,
    agency.acronym AGENCY_ACRONYM,
    agency.expiration_date AGENCY_EXP,
    agency.post_count AGENCY_POST,
    agency.stat AGENCY_STAT,
    agency_type.agency_type AGENCY_TYPE,
    division.division_id DIV_ID,
    division.name DIV_NAME,
    division.transfer_number DIV_TRANS_NUM,
    division.expiration_date DIV_EXP,
    division.post_count DIV_POST,
    division.stat DIV_STAT,
    service.service_id SVC_ID,
    service.name SVC_NAME,
    service.taxonomy SVC_TAX,
    service.keywords SVC_KEYWORDS,
    service.action_type SVC_ACTION_TYPE,
    service.sr_form_name SVC_SR_FORM,
    service.expiration_date SVC_EXP,
    service.post_count SVC_POST,
    service.stat SVC_STAT,
    faq.faq_id FAQ_ID,
    faq.name FAQ_NAME,
    faq.expiration_date FAQ_EXP,
    faq.post_count FAQ_POST,
    faq.stat FAQ_STAT
    FROM
    agency,
    agency_type,
    division left join service on
    division.division_id=service.division_id left join
    faq on service.service_id=faq.service_id
    WHERE (
    (agency_type.agency_type_id = agency.agency_type_id)
    AND (agency.agency_id = division.agency_id)
    AND (agency.agency_id = :agency_id )
    It's very fast -- I can retrieve and display 5,000 rows
    in seconds using Perl DBI and CGI -- and very easy to use
    to produce the hierarchical listing of items from the
    four tables. It is also very straightforward since I was
    able to generate the SQL using the SQL modeler in TOAD
    (I'm not the strongest SQL developer so I resort to
    tools).
    I need to get jump-started in the right direction to
    determine what I need to add to my division table
    (div_parent_id?), if I need a div_parent_child table to
    define the relationships (rows with parent_id & child_id
    pairs), and how to change or rewrite the SQL query. The
    CGI form that will be used to define the relationships
    will ask users to define children of a given division. I
    envision presenting a list of divisions with null
    parent_division_id columns for users to select from then
    updating selected rows for selected divsions.
    Thanks in advance for any help/guidance!
    -Gene

    INLINE VIEWS!
    select whatever_you_want
    from (
    SELECT FOLDER_ID, PARENT_FOLDER_ID, FOLDER_NAME
    FROM FOLDERS
    START WITH PARENT_FOLDER_ID = 0 CONNECT BY PARENT_FOLDER_ID = PRIOR FOLDER_ID
    ) tree, FILES
    where tree.folder_id = files.folder_id -- or something like that
    always try to keep the CONNECT BY limited to ONE AND ONLY table. then use that query in a subquery, a WITH clause, an inline view or something. do not try to JOIN or UNION with a CONNECT BY. it won't work the way you think it will, and even it returns the expected results, it will perform terribly.
    * your mileage may vary
    Message was edited by:
    shoblock
    added exclamation marks to show my excitement!!!!

  • URGENT - need help with ansi/iso outer joins

    Hi,
    I am currently preparing for the OCP sql exam for the 9i developer track and I think a statement is printed wrong in my study book, please could somebody confirm the following:-
    Oracle Outer Join syntax
    from tab_a, tab_b
    where a.col_1 (+) = b.col_1
    ANSI/ISO Equivalent
    from tab_a a left outer join tab_b b
    on a.col_1 = b.col_1
    Should n't the above be a right outer join
    Please could somebody confirm or explain if I am wrong.
    Thanks in anticipation.
    Simon
    Note. The book is OCP Introduction to 9i sql (1Z0-007) page 115 (table 3-1) - author Jason Couchman

    It seems so....
    See
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_103a.htm#2107297

  • Business user  needs to view tables with out SE16 access

    Hi ,
    There is a requirement where  business user  ( Data team)    need to view some master and transactional data tables  in  production . But , as per our process , end users will not  be given SE16  access .
    Is there any solution where we can allow the end user  to view tables with out SE16 access ?
    Thanks in advance .
    Thanks .
    Dharma.

    Hi,
    Using Function Module C160_TRANSACTION_CALL you can call any tcode which dont have access..
    Create a report  and call function module and pass se16 to parameter .
    CALL FUNCTION 'C160_TRANSACTION_CALL' "
      EXPORTING
        i_tcode =        'SE16'            " sy-tcode
      EXCEPTIONS
        ILLEGAL_INPUT = 1           "
        INTERNAL_ERROR = 2          "
        .  "  C160_TRANSACTION_CALL
    now create a tcode for this report as ZSE16.,
    hope this helps u.,
    You can also create Data browser ( SE16 ) in report and display as ALV., using Field Symbols and RTTS.
    Thanks & Regards,
    Kiran

  • Query Needed for Partitioning table

    Hi,
    I have created a table called Test. There is a column named business_name.
    There are several businesses like ABC,BCD,ADE....
    There will be lakhs of rows corresponding to each business, i mean there will be lakhs of entires corresponding to ABC,BCD....
    So i like to partition the table according to business_name so that the search will be more faster.As we had partitioned according to the business_name, i hope we need to search only on the partition corresponding to the particular business.
    can any one provide the Query to partition the table ' TEST ' according to the column ' business_name ' .
    Also can anyone provide Query to modify the already existing table ' TEST ' to incorporate partition for the column ' business_name '.

    We can partiton a table by the following
    create table Generalledger (
         record_id     number,
         business_name     varchar2(3)
         sales_dt     date,
         amount     number(10)
    partition by list (business_name)
    partition ct values ('ABC'),
    partition ca values ('BCD'),
    partition def values (default)
    But if we dont know the values like 'ABC' , 'BCD'
    ....how can we do the partitionuse SQL to generate part (or all) of your DDL statement. The following will output one partition statement for each business_name:
    SELECT DISTINCT 'partition p_' || BUSINESS_NAME || ' values (''' ||
                     BUSINESS_NAME || '''),'
    FROM GENERALLEDGER;

  • Multiple table on Outer Join

    Hi,
    Does anyone knows how you can explain, in ANSI SQL 1999, the outer join with more than two tables ?
    Here is an example in the old Oracle 8i syntax:
    select a.col1,b.col2,c.col3
    from a, b, c
    where a.col1 = b.col1 (+) and
    a.col1 = c.col1 (+)
    Thank in advance
    Alessandro

    Try this:
    select a.col1, b.col2, c.col3
    from a left outer join b on (a.col1 = b.col1)
    left outer join c on (a.col1 = c.col1);

  • SAP query change the internal table extracted after a join instruction

    Hi Gurus
    I would like to know if it is possible to change the data in internal table after that the
    join instruction has been executed .
    I should have to delete some lines extracted if some conditions are satisfied.
    Do you think that it is not possible and it is better to crete a program?
    Thanks in advance

    HI,
    use select and end select.
    select single msegbukrs msegwerks msegmatnr msegmenge msegaufnr msegsmbln msegbwart msegshkzg mseg~meins
             afkorsnum afpoverid
             maststlnr maststlal stpoidnrk stpomenge stpomeins stkobmeng
         into (itab-mblnr,
               itab-budat,
               itab-bktxt,
               itab-bukrs,
               itab-werks,
               itab-matnr,
               itab-menge,
               itab-aufnr,
               itab-smbln,
               itab-bwart,
               itab-shkzg,
               itab-meins,
               itab-rsnum,
               itab-verid,
               itab-stlnr,
               itab-stlal,
               itab-matnr_r,
               itab-bdmng,
               itab-meins_r,
               itab-bmeng)
         from mkpf
         inner join mseg on msegmblnr eq mkpfmblnr and mkpfmjahr eq msegmjahr
         inner join mara on maramatnr eq msegmatnr
         inner join afpo on afpoaufnr eq msegaufnr
         inner join mast on mastmatnr eq msegmatnr and mastwerks eq msegwerks
         inner join afko on afkoaufnr eq msegaufnr and afkostlal eq maststlal
         inner join stko on stkostlnr eq maststlnr and stkostlal eq maststlal
         inner join stpo on stpostlnr eq stkostlnr
         inner join stas on stasstlnr eq maststlnr and stasstlal eq maststlal and stasstlkn eq stpostlkn
         where mseg~werks in s_werks
         and mseg~matnr in s_matnr
         and mkpf~budat in s_budat
         and mseg~aufnr in s_aufnr
         and mseg~bwart eq '101'
         and mast~stlan eq '1'
         and stko~stlty eq 'M'
         and stpo~stlty eq 'M'.
    if condtion .
        append: itab.
    endif.
        clear: itab.
      endselect.
    Edited by: ZAHID HAMEED on Oct 12, 2011 3:56 PM

  • SAP QUERY LOOPS AND INTERNAL TABLE

    Hi All, I have a query which i have made. It runs from Table EKPO which has PO details and what I want to do is now via ABAP Code pull through the total of goods receipt for the PO and Line Item into a field. Sounds Easy enough..Problem now,
    The table which contains the GR data is EKBE which agains a PO and Line Item can have many 101 movements and 102 movements so what I want is an ABAP Statent to basically sum up the total of 101 for the PO & LINE ITEMS and then minus this from the total of 102 for the PO & LINE ITEMS and post the result in to this new field I have created.
    I am pretty decent with ABAP Code in Querys I.e Select statements etc but from what I can see i need to create an internal table and do a loop and collect statement but I keep on failing due to not enough knowledge. Please can some one help me with this and provide me with the code and explanation as i would like to understand,
    POINTS WILL BE REWARDED
    Thanks
    Kind Regards
    Adeel Sarwar

    Hi,
    This is the full code i have entered but its not working. Any help would be appreciated. If you could rectify the code and internal tables that would be great.
    Thanks
    TABLES: EKBE.
    DATA: PurO LIKE EKPO-EBELN,
          POLI LIKE EKPO-EBELP.
    *New Table and Vars defined
    DATA:   BEGIN OF IT_EKBE,
              IT_EKBE LIKE EKBE,
            END OF IT_EKBE.
    DATA:  BEGIN OF IT_SUM OCCURS 0,
              EBELN TYPE EBELN,
              EBELP TYPE EBELP,
              DMBTR TYPE DMBTR,
              MENGE TYPE MENGE,
          END OF IT_SUM.
    CLEAR: QTYD.
    MOVE: EKPO-EBELN TO PurO,
          EKPO-EBELP TO POLI.
    SELECT * FROM EKBE INTO IT_EKBE
        WHERE EBELN = PurO
        AND   EBELP = POLI
        AND   BEWTP = 'E'
    LOOP AT IT_EKBE.
      MOVE CORRESPOING IT_EKBE TO IT_SUM.
      IF IT_EKBE-BWART = '102'.
        IT_SUM-DMBTR = IT_SUM-DMBTR * -1.
        IT_SUM-MENGE = IT_SUM-MENGE * -1.
      ENIDF.
      COLLECT IT_SUM.
      CLEAR IT_SUM.
    ENDLOOP.
    ENDSELECT.
    If sy-subrc = 0.
      QTYD = IT_SUM.
    ELSE.
      QTYD = 0.
    ENDIF.

  • Joining tables via SQL

    I am trying to join two tables.  I have a documents and uploads, of which user is common.  For the user, I would like results put out from the tables where it is owned by the same user.  So if they have two records in uploads, and one in documents, it puts all of those out.  Also, how do I put out the data.  For example, if it is a document, then access the document variables?
    $sql="SELECT *
    FROM documents
    FULL JOIN uploads
    ON documents.user = uploads.user";
    Error:
    Sql Error: Unknown column 'documents.user' in 'on clause'

    I've updated it:
    $sql="SELECT *
    FROM documents, uploads
    WHERE documents.user = uploads.user AND documents.user='$profileIDNum'";
    I get two test text files, but they have different date stamps some how.  There is only one Test Text file in uploads.  In documents, there are two records.  I noticed when I change one of the dates for the records in documents, it changes the date for the Test Text file listed.

Maybe you are looking for

  • So i downloaded photoshop, but it is no where to be found on my computer.

    It says up to date next to the completed download, and i have a file folder i found searching my computer, but that is empty as well. I have windows 8 n supposedly it's supposed to come up in my start up window, but it's not there. I don't know what

  • There was an error processing a page. a number is out of range.

    When I open a PDF generated from a classic ASP application, some particular documents fail when accessing a page: there was an error processing a page. a number is out of range. This only happens in Adobe Reader 10 and 11. The ASP page has a code sim

  • Can Time Machine back up an external hard drive plugged into a Time Capsule

    I have iTunes and iPhoto libraries that have outgrown the hard drive on my laptop so I've moved them on to an external hard drive. Since I'd like to move around the house with the laptop, I've plugged the external hard drive in to the Time Capsule so

  • Crs install fail

    Oracle 10g Red Hat linux hi all, I'm trying to install crs 10.2.0.1 on rhel5.4 64 bit all goes well untill the end of the install, and I have to run root.sh, but it says: failed to upgarde oracle cluster registry configuration. Please help, have no i

  • Slideshow playback has no music. Suggestions?

    Hi All, Running latest LR 1.3.1, on a MacBook Pro 15" Intel, with latest Leopard updates. Lightroom Slideshow will play fully normal with transitions, etc., using both factory and custom user-adjusted settings. Looks great, except, there is no music.