Outer Join on 10 tables

Hi:
I am attempting to create a view using an outer join on 10 different Oracle tables and I can't seem to get the syntax right because not all of the information that should appear in the VIEW is appearing. Below is the syntax for the VIEW:
CREATE VIEW dwgSearchEngineResults AS
   SELECT Drawing.dwgID, Drawing.PMDwgNum, Drawing.Type, Drawing.Title, Drawing.dwgSize,
          Drawing.projectNum, Panel_Number.panlnumID, Panel_Number.panlNumber, Discipline.disciplineID,
          Discipline.drawingType, Area.areaID, Area.areaNum, Asset_Number.assetnumID, Asset_Number.assetNumber,
          Vendor.vendorID, Vendor.Name
   FROM AJM.Drawing, AJM.Discipline, AJM.Panel_Number, AJM.Dwg_Panel_Number, AJM.Area,
        AJM.Dwg_Area, AJM.Asset_Number, AJM.Dwg_Asset_Number, AJM.Vendor, AJM.Vendor_Drawing
   WHERE Drawing.disciplineID = Discipline.disciplineID(+) AND Drawing.dwgID = Dwg_Panel_Number.dwgID(+)
         AND Dwg_Panel_Number.panlNumID = Panel_Number.panlNumID(+) AND Drawing.dwgID = Dwg_Area.dwgID(+)
         AND Dwg_Area.areaID = Area.areaID(+) AND Drawing.dwgID = Dwg_Asset_Number.dwgID(+)
         AND Dwg_Asset_Number.assetnumID = Asset_Number.assetnumID(+) AND Drawing.dwgID = Vendor_Drawing.dwgID(+)
         AND Vendor_Drawing.vendorID = Vendor.vendorID(+);I attempted to Bold the main tables for you, but the tags don't seem to be working. So the tables that you see in the FROM clause with the tags are the main tables and the rest are bridge tables that take away the many - to - many relationship between the main tables.
As I said earlier, the outer join isn't working right because for example, I know for sure that there area 3 Vendor names in the Vendor table. However, when I select the vendor name from the VIEW, none of the names appear. It should be noted that the none of the dwgID's are in the Vendor_Drawing table since none of the drawings are Vendor drawings. Is that why the 3 vendor names don't appear in the VIEW? Also, I know there are 2 area numbers in the Area table. Again, when I select the area number from the VIEW, I only get 1 area number that displays, and that's the one that the dwgID and the areaID match in the Dwg_Area table.
This is a search engine that I'm developing and I thought it would be easier to write a VIEW since the users can search for different parameters from either of these tables. I know this is pretty complex, but can someone please help me.

Oops, that was meant to be a cross-post notification...
Cross post:
http://forum.java.sun.com/thread.jsp?forum=48&thread=502319&start=0&range=15#2376543

Similar Messages

  • Left outer join using multiple table

    Hi,
    I am trying to use left outer join with multiple tables , the join condition will be based on  PERNR and BEGDA & ENDA for each infotype in selection screen.
      select pa00~pernr pa00~begda pa00~endda pa00~massn pa00~massg pa00~stat2 pa00~aedtm pa00~uname
        pa01~begda pa01~endda pa01~bukrs pa01~persg pa01~persk pa01~mstbr pa01~ename pa01~aedtm pa01~uname
        pa02~begda pa02~endda pa02~nachn pa02~vorna pa02~midnm pa02~aedtm pa02~uname
        pa016~begda pa016~endda pa016~cttyp pa016~aedtm pa016~uname
        into CORRESPONDING FIELDS OF TABLE i_pall
        from  ( PA0000 as pa00 left OUTER JOIN pa0001 as pa01 on pa00~pernr = pa01~pernr )
        left OUTER JOIN pa0002 as pa02 on pa00~pernr eq pa02~pernr )
        left OUTER JOIN  pa0016 as pa016 on pa00~pernr eq pa016~pernr )
        where pa00~pernr in S_pernr
        AND pa00~begda in s_bg0000
        and pa00~endda in s_nd0000.
    but this fails  to fetch the value of begda enda from each pa0000,pa0001,pa0002,pa0016.
    Please help!
    Monirul

    Why don't you use the standard logical database PNPCE and then Provide statement?

  • Maximum number of tables that can be outer joined with one table in a query

    Hi All,
    Iam new to sql, so can you please let me know What is the maximum number of tables that can be outer joined with one table in a query?
    Thanks,
    Srini

    srinu2 wrote:
    Iam new to sql, so can you please let me know What is the maximum number of tables that can be outer joined with one table in a query?
    There is no limit to the number of tables you can outer join as long as you join them correctly.
    SQL> with a as
      2      (
      3      select 1 id, 2 b_key, 3 c_key from dual union all
      4      select 2 id, 1 b_key, 4 c_key from dual union all
      5      select 3 id, 3 b_key, 1 c_key from dual union all
      6      select 4 id, 4 b_key, 2 c_key from dual
      7      ),
      8      b as
      9      (
    10      select 1 id, 1 c_key2 from dual union all
    11      select 2 id, 5 c_key2 from dual union all
    12      select 3 id, 3 c_key2 from dual union all
    13      select 4 id, 2 c_key2 from dual
    14      ),
    15      c as
    16      (
    17      select 1 key1, 1 key2, '1-1' dta from dual union all
    18      select 1 key1, 2 key2, '1-2' dta from dual union all
    19      select 1 key1, 3 key2, '1-3' dta from dual union all
    20      select 1 key1, 4 key2, '1-4' dta from dual union all
    21      select 2 key1, 1 key2, '2-1' dta from dual union all
    22      select 2 key1, 2 key2, '2-2' dta from dual union all
    23      select 2 key1, 3 key2, '2-3' dta from dual union all
    24      select 2 key1, 4 key2, '2-4' dta from dual union all
    25      select 3 key1, 1 key2, '3-1' dta from dual union all
    26      select 3 key1, 2 key2, '3-2' dta from dual union all
    27      select 3 key1, 3 key2, '3-3' dta from dual union all
    28      select 3 key1, 4 key2, '3-4' dta from dual union all
    29      select 4 key1, 1 key2, '4-1' dta from dual union all
    30      select 4 key1, 2 key2, '4-2' dta from dual union all
    31      select 4 key1, 3 key2, '4-3' dta from dual union all
    32      select 4 key1, 4 key2, '4-4' dta from dual
    33      )
    34  select d.a_id, d.b_id, c.key1 as c_key1, c.key2 as c_key3, c.dta
    35  from
    36      c,
    37      (
    38      select
    39          a.id as a_id, b.id as b_id, a.c_key, b.c_key2
    40      from a, b
    41      where a.b_key = b.id
    42      ) d
    43  where d.c_key = c.key1 (+)
    44  and   d.c_key2 = c.key2 (+);
          A_ID       B_ID     C_KEY1     C_KEY3 DTA
             3          3          1          3 1-3
             4          4          2          2 2-2
             2          1          4          1 4-1
             1          2
    SQL>

  • How to use outer join on 3 tables

    how to use outer join on 3 tables
    say tables are mkpf,lips and vbrp
    mkpf-xblnr = lips-vbeln
    lips-vbeln  = vbrp-vgbel

    refer following querry
        select a~bukrs
               a~anln1
               a~ord42
               a~ord43
               b~afabe
               b~ndabj
               b~kaafa
               b~aafag
               c~kostl
               d~afasl
               d~ndjar
               d~ndper
        into corresponding fields of table gt_master
        from ( ( anla as a inner join anlc as b
        on abukrs = bbukrs
        and aanln1 = banln1
        and aanln2 = banln2 )
        inner join anlz as c
        on  abukrs = cbukrs
        and aanln1 = canln1
        and aanln2 = canln2 )
        inner join anlb as d
        on  abukrs = dbukrs
        and aanln1 = danln1
        and aanln2 = danln2
        where a~bukrs in s_comp.

  • Oracle outer join on  multiple tables throws error

    Hi ,
    We are using ansi joins with outer joins on multiple tables in oracle 9i.
    Now these queries have to be used in Oracle8i.
    Since Oracle8i does not support ansi sql we are replacing the ansi sql queries with the oracle joins.
    On trying the same we found that the following query
    select *from tab1 a, tab2 b, tab3 c where a.c1 = b.col1(+) and c.c2 = b.col2 (+)
    throws the error
    ORA-01417: a table may be outer joined to at most one other table.
    Is there a way to simulate this query without using the outer joins on multiple tables?
    thanks

    Try writing the query in this form:
    select * from
    (select t1.col1, t1.col2
    from schema.table1 t1, schema.table2 t2
    where t1.col1 = t2.col1(+)) t4,
    schema.table3 t3 where t4.col2 = t3.col2(+)
    In the subquery, you will have to list all the columns you want to see, and you will need to provide unique aliases for any columns with duplicate names. I tested this on 9i, and don't have an 8i system to work with, so I hope this helps.

  • Case statement resulting into Left outer join with other tables

    Hi All ,
    I am facing a stuation where a Case statement on one of the logical columns in Answers is resulting into a left outer join with a table in the query.
    If we remove the case stmt, the table is not being acessed.
    The case stmt is a simple one and no other logical column is being accessed in the case stmt.
    Please advice .
    Thanks.

    Hi Sai,
    No ..we dont have any left outer join ...its just that I am selecting measure from F1 which has a confimred dimension D1 with F2.Now when I dont have case stmt on measure from F1(Case stmt is something like : CASE WHEN "- P table"."P Column" = 'Y' THEN 'Right' ELSE 'Wrong' END), then it doesnt query F2.
    However as soon as I introduce the case stmt ,the query creates a left outer join with F2.
    Thanks.

  • Outer Join for 2 Tables?

    Hi,
    i have 3 Tables, one is the "main" table.
    Table1
    Col1
    Col2
    Col3
    Table2
    Col2
    Col4
    Col5
    Table3
    Col4
    Col6
    Now i want all hits from Table 1, all outer join hits from table 2 and the regarding rows from table 3.
    The join from Table1 to Table2 is no problem, but how to add table3?
    SELECT *
        FROM table1 AS t1
              LEFT OUTER JOIN table2 AS t2
                    ON t2col2 = t1col2
       INTO CORRESPONDING FIELDS OF TABLE      result
        WHERE t1~col1 IN so_col1.

    Hi,
    a right table in an outer join cannot become a part of an inner join or an outer join. So you will have to use some other technique.
    meaing table1 connects to table2 with an outer join resulting in all rows table1 and cooresponding if existing from table2, now table2 is the right table it cannot make a join with table3. inner or outer.
    regards,
    Khusro Habib

  • Left Outer Join on same table clarification

    HI,
    I have a table that gets populated from 3<sup>rd</sup> party system. We don’t have control over it. So, the table has master record (master) and children. Master type is 78 and children’s type is 64. So, it looks like this. In the 3<sup>rd</sup>
    party system, if Master transaction gets cancelled, it is recorded as type 178. If child is cancelled, then it is 164. Once the child is cancelled and created again using one process then newly created transaction will have 65 as type. Same thing with Master
    cancelled transaction also. It will be 79. So, to summarize:
    Master:                                                                                                                                                                      
    Brand New Transaction type = 78
    Cancelled Transaction type = 178
    Cancelled with creation transaction type = 79
    Child:
    Brand New Transaction type = 64
    Cancelled Transaction type = 164
    Cancelled with creation transaction type = 65
    I don’t have to bother about master records. I need to focus on only children for my query.
    ID
    TxnID
    Master
    Type
    TDate
    Location
    193075
    211554
    211543
    64
    20140805
    ABC
    193076
    211555
    211543
    64
    20140805
    NBC
    193077
    211556
    211543
    64
    20140805
    ABC
    193080
    211559
    211558
    64
    20140805
    ABC
    193081
    211562
    211561
    64
    20140805
    ABC
    193082
    211565
    211564
    64
    20140805
    CBC
    193083
    211565
    211564
    164
    20140805
    CBC
    193084
    211566
    211564
    65
    20140805
    AZC
    --drop
    table #Transactions
    CREATE
    TABLE #Transactions
    ID
    int,
    TxnID
    int,
    mstTicket
    int,
    Typecode
    int,
    Tdate
    datetime,
    Location
    varchar(10)
    select
    * from
    #Transactions
    Insert
    into #Transactions
    (ID,
    TxnID,
    mstTicket,Typecode,Tdate,Location)
    Select 193075, 211554,211543,64,'2014-08-05','ABC'
    UNION ALL
    Select 193076, 211555,211543, 64,
    '2014-08-05',
    'NBC' UNION ALL
    Select 193077, 211556, 211543, 64,
    '2014-08-05',
    'ABC' UNION
    ALL
    Select 193080, 211559, 211558, 64,
    '2014-08-05',
    'ABC' UNION
    ALL
    Select 193081, 211562, 211561, 64,
    '2014-08-05',
    'ABC' UNION
    ALL
    Select 193082, 211565, 211564, 64,
    '2014-08-05',
    'CBC' UNION
    ALL
    Select 193083, 211565, 211564, 164,
    '2014-08-05',
    'CBC' UNION
    ALL
    Select 193084, 211566, 211564, 65,
    '2014-08-05',
    'AZC'
    select
    T.TxnID,
    T.TypeCode,
    T.Location,
    TL.TxnID
    From
    #Transactions T
    Left Outer
    JOIN #Transactions
    TL ON
    TL.TxnID
    = T.TxnID
    and TL.TypeCode
    = 164
    select
    T.TxnID,
    T.TypeCode,
    T.Location,
    TL.TxnID
    From
    #Transactions T
    Left Outer
    JOIN #Transactions
    TL ON
    TL.TxnID
    = T.TxnID
    and TL.TypeCode
    = 164
    Where
    T.typecode
    in (64, 65)
    I need a clarification regarding left Outer Join. 
    In the first left outer join query both 64 and 164 both have TL.TxnID populated. Why is that?. What I understand from
    left outer join is that ‘Returns all the rows’ from left table and only matching data from right table.
    Here, matching row from right table is 211565 and 164 record (id 193083). So, only it should have TxnID populated. But row 211565 and 64 has TL.txnID getting populated (ID 193082).
    Why is it? Am I not understanding left out join properly?
    Thanks,

    Thank you Shailesh. I understood what join does in left outer join. I was thinking
     Left Outer JOIN #Transactions TL ON TL.TxnID = T.TxnID and TL.TypeCode = 164 is same as
    Left Outer JOIN #Transactions TL ON TL.TxnID = T.TxnID and TL.TypeCode = T.TypeCode
    and TL.TypeCode = 164
    #Transactions
    T
    Left
    Outer
    JOIN
    #Transactions
    TL
    ON
    TL.TxnID
    =
    T.TxnID
    and
    TL.TypeCode
    = 164
    Where
    T.typecode
    in
    (64,
    65)

  • How to use outer join on 2 tables with Oracle 8i

    Could anyone tell me the Oracle 8i syntax equivalent to :
    select user.name, city.adress, contry.name
    from user
    left outer join city on (user.rCity = city.code)
    left outer join country on (user.rCountry = country.code)
    I tried following :
    select user.name, city.adress, contry.name
    from user, city, contry
    where user.rCity (+) = city.code
    and user.rCountry (+) = country.code
    but displayed following error :
    ORA-01417: a table may be outer joined to at most one other table
    Thank you

    Logically I would expect a user to have a city and a country, or not. In that case the outer join should be on the other tables. Making your query:
    select user.name, city.adress, country.name
    from user, city, country
    where user.rCity = city.code (+)
    and user.rCountry = country.code (+);

  • How to use outer join in Target table

    hi all:
    how to use outer joing and trunc in target table?

    Good morning,
    Can you be more specific?
    What do you want to join, what needs to be truncated, what's the Loading Type of your target table-object, etc.
    In general the following applies.
    An outer join is specified on the JOIN operator, under Operator Properties you can specify the Join Condition, for example:
    tab1.uk_col1 = tab2.uk_col1(+)
    and
    tab1.uk_col2 = tab2.uk_col2(+)Truncating a table in a mapping can only be done in combination with inserting the dataset, setting the loading type of a table to TRUNCATE/INSERT.
    Apart from that there is a predefined OWB transformation called WB_TRUNCATE_TABLE, this can also be used to truncate a table.
    Cheers, Patrick

  • Outer join with nested tables

    I am dealing with a nested table (I simplified the case
    for purpose of posting):
    CREATE TABLE boris_main_tab (
    IND_SSN          VARCHAR2(9) PRIMARY KEY,
    children          B_CHILDREN_TBL,
    ) nested table children stored as....
    where B_CHILDREN_TBL is defined like this:
    create or replace type b_children_type as object (
         child_ssn               VARCHAR2(9),
         child_first_name          VARCHAR2(20),
         child_last_name          VARCHAR2(20),
         child_dob               date
    create or replace type b_children_tbl as table of b_children_type;
    if I want to display person's ssn along with his/her children information I do like this:
    SELECT m.ind_ssn, c.child_ssn, c.child_first_name
    FROM boris_main_tab m,
    TABLE(m.children) c
    This is a statement I can find everywhere. But there is a caveat here, they
    forgot to mention. This is really an inner join, so I don't get childless
    people. Can you, guys, help me with the outer join syntax?
    I mean, of course, I found the obvious solution to make this inner join
    into a view and then join it with the boris_main_tab again this time using the
    regular outer join syntax. But it seems to me there has to be something simplier than that.
    But I can't find it. It really hurting me, since I have a few nested table
    columsn and people want to see the records where I need to mention a few of
    them, sort of like
    from boris_main_tab m, TABLE(m.children) c, TABLE(m.spouses) s
    where c.child_last_name <> m.spouse.last_name
    in cases like this the fact that EACH of these joins is inner join really
    hurts the logic.
    Respectfully,
    Boris

    Hi Borris,
    Found the following in the Oracle Documentation under: Oracle8i Application Developer's Guide - Object-Relational Features Release 2 (8.1.6)
    2 Managing Oracle Objects / Using Collections / Collection Unnesting
    URL: http://www.znow.com/sales/oracle/appdev.816/a76976/adobjmng.htm#1002885
    Oracle8i also supports the following syntax to produce outer-join results:
    SELECT d.*, e.* FROM depts d, TABLE(d.emps)(+) e;
    The (+) indicates that the dependent join between DEPTS and D.EMPS should be NULL-augmented. That is, there > will be rows of DEPTS in the output for which D.EMPS is NULL or empty, with NULL values for columns
    corresponding to D.EMPS.

  • Outer join between logical tables

    Hello,
    This question is likely to be asked many times, but I failed to find the proper thread in the forum.
    Assume there are 2 logical tables "Fact" and "Dim".
    "Fact" has 1 LTS which consists of physical tables F, FX1, FX2 which are inner joined.
    "Dim" has 1 LTS which consists of physical tables D, DX1, DX2 which are inner joined.
    F and D tables are also joined together on physical layer.
    I define left outer join between "Fact" and "Dim" on logical layer.
    I create a request in Answers, querying columns from "Fact" and "Dim" which map to physical tables F and D only.
    I expect OBIEE to build SQL query which uses F and D tables only, outer joined.
    Instead of that all the physical tables used for logical tables "Fact" and "Dim" are joined together in a form like:
    SELECT F.col, D.col
    FROM (F inner join FX1 inner join FX2) left outer join (D inner join DX1 inner join DX2)
    Is there any way to avoid this behavior or build data model in different way?
    Thank you!

    Hi Alex,
    In BI Applications you never have a null in a facts foreign key to the dimension. Instead there is always a zero row wi record inserted with 'Unspecified' in all the columns. When the fact table is populated in the ETL, if the fact record doesn't have a corresponding dimension record the WID is poulated with zero.
    This removes the problems with outer joins and helps considerably with performance.
    This could be one practice you take from BI Apps and put into your own ETL's and data model.
    Regards
    Robin

  • Outer join on multiple tables

    Hi All,
    I need to create multiple outer join in Discoverer.
    My requirements is like this
    I have a report where in I show the sales of components. I have Year as page item in Discoverer cross tab.
    I have 2 years in my year table, 1999 and 2000
    in the components table I have 3 components, X, Y, Z
    In the fact table, I have 5 records as below
    YEAR     PRODUCT     AMOUNT
    1999     X     100
    1999     Y     200
    1999     Z     300
    2000     X     400
    2000     Y     500
    Now with this data, when I create a cross tab with year as page item, I get the following output on selecting 1999 as year in page item,
    component     Amount SUM
    X     $100
    Y     $200
    Z     $300
    similarly when I get report for 2000 it will be as follows
    component     Amount SUM
    X     $400
    Y     $500
    Now I want some way to get a report as below for 2000 and similar cases
    component     Amount SUM
    X     400
    Y     500
    Z     0
    Can some body help me??
    Thanks,

    Hi Mrutyunjay,
    If you keep the query as described by Csaba but leave out time_period.year from the SELECT and GROUP BY list. In addition, replace the SUM(...) function with the following expression.
    SUM (CASE WHEN <condition> THEN fact_tab.amount ELSE 0 END)
    Where <condition> will be along the lines of 'time_period.year = 1999'.
    This will give you the result you require.
    Do be aware that this will force Oracle to do a full scan on the fact_tab table. This may render the solution unworkable.
    Cheers,
    denty.

  • Left Outer Joining multiple tables to one source table FAILS with VLD-1511

    Hi all,
    Is it me, or is OWB unable to handle left outer joining 1 source table to multiple other tables?
    I want to load a fact table so I have 1 source table with measures. This table must be outer joined to some dimensions that have their FK in the fact table.
    The SQL statement would look like this (and is perfectly valid):
    select ...
    from input, dim1, dim2
    where input.c1 = dim1.c1(+)
    and input.c2 = dim2.c2(+);
    I put the where clause in the joiner operator and validate, but that gives me message VLD-1511: A table may be outer joined to at most one other table.
    Even splitting this up into one outer join per joiner still gives this message.
    A search and look around on the forum and on metalink shows there are related issues (like bug 3334035). Seemingly creating a view is the work-around to use.....? (ie downgrading owb to a simple gui tool) }-;
    Have other people experienced this problem of not being able to outer join one input table to multiple other tables?
    Thanks,
    Ed

    I have had some feedback from Oracle. It turns out this has to do with 2 issues. Below I have pasted the text that Support gave me:
    <---------- START QUOTE ---------->
    RESEARCH
    =========
    Bug 3437036 KEY LOOKUP DOES NOT DETECT ORA-1417 IN VALIDATE/GENERATE STEP
    Unpublished Bug 4211684 FORWARD PORT OF BUG 3437036
    shows:
    Some more development has been completed when this bug is fixed in Paris.
    The following are the details:
    1. If the join condition contains a full outer join such as
    tab1.c (+) = tab2.c (+) and tab2.c (+) = tab3.c
    then the new validations implemented for this bug do not apply since
    in OWB, full outer join triggers generation of joins in ANSI syntax.
    ANSI syntax does not have the original problem the base bug of this
    bug reported.
    2. If the join condition does not contain any full outer join condition,
    then the join is generated in Oracle join syntax, which is subject two
    several restrictions. The fix to this bug check two of the restrictions.
    3. The first restriction in Oracle syntax is that the outer join operator
    "(+)" can only directly be attached to a column name. If you attach it
    to an expression, such as the following:
    (tab1.c + 1) (+) = tab2.c
    Then there will be an ORA-936 error at the time of mapping deployment.
    For this case, I have added a validation message VLD-1512 to error out
    this situation.
    4. The second restriction in Oracle syntax is that a table can only be
    outer joined to exactly one other table.
    For example, this is an invalid join in Oracle syntax:
    tab1.c (+) = tab2.c and tab1.d (+) = tab3.d
    because tab1 is left outer joined to tab2 and tab3.
    But note that the following is still valid in Oracle syntax:
    tab1.c (+) = tab2.c and tab1.d = tab3.d (+)
    because tab1 is left outer joined to tab2 and right outer joined to tab3.
    So this latter case does not violate the restriction that "same oj" to
    more than 1 table is not allowed.
    If same oj to more than 1 table is specified in a join condition,
    VLD-1511 will be issued, and the map is made invalid.
    <---------- END QUOTE ---------->
    OWB does a partial validation, ie not all access paths are (can be) checked. A full check is only done by the database itself. So some scenarios (like checking whether multiple tables are outer joined the correct way) are not checked, and in this case are flagged with an error (even though it is actually a correct scenario).
    Seemingly this was not flagged with an error in earlier versions of OWB, so beware, OWB behaviour may change when upgrading...
    Alternative solutions are (1) using key lookups, (2) using a view with all outer joins in there, (3) using intermediate result tables between the joins.
    Hope this info helps some people prevent spending too much time on a false error message,
    Ed

  • Outer join two tables with two keys

    Hi,
    I have a question regard outer join,
    I have table A (Aid, ADesc), Table B(Bid, Bdesc), and Table C (Aid, Bid, Cdesc)
    There is data in Table A and B, but Table C is empty
    I want to outer join C with A and B with below query
    select ADesc,Bdesc, Cdest
    from A, B, C
    where A.Aid=C.Aid(+) and B.Bid(+)=C.Bid
    and A.Aid='XXX' and B.Bid(+)='ZZZ'
    The query result show only data in column Adesc , but column BDesc is empty even though there are some data in table B.
    How should the query been modified to correctly show ADESC and Bdesc.
    Thanks
    Vincent

    Guess the below should work:
    Case when records are available in Table C:
    with a as
    (select 'XXX' aid, 'adesc' adesc from dual),
    b as
    (select 'ZZZ' bid, 'bdesc' bdesc from dual),
    c as
    (select 'XXX' aid, 'ZZZ' bid, 'cdest' cdest from dual where 1 = 1)
    select ADesc,Bdesc, C1.Cdest
    from
    A LEFT OUTER JOIN C c1 ON (A.AID = C1.AID AND A.AID = 'XXX'),
    B LEFT OUTER JOIN C C2 ON (B.BID = C2.BID AND B.BID = 'ZZZ');
    Output:
    "ADESC"     "BDESC"     "CDEST"
    "adesc"     "bdesc"     "cdest"Case when table C is empty:
    with a as
    (select 'XXX' aid, 'adesc' adesc from dual),
    b as
    (select 'ZZZ' bid, 'bdesc' bdesc from dual),
    c as
    (select 'XXX' aid, 'ZZZ' bid, 'cdest' cdest from dual where 1 = 2)
    select ADesc,Bdesc, C1.Cdest
    from
    A LEFT OUTER JOIN C c1 ON (A.AID = C1.AID AND A.AID = 'XXX'),
    B LEFT OUTER JOIN C C2 ON (B.BID = C2.BID AND B.BID = 'ZZZ');
    "ADESC"     "BDESC"     "CDEST"
    "adesc"     "bdesc"     ""

Maybe you are looking for