Multiple Outer join in ORACLE 8.1.6

Hi ,
Can anybody suggest me how can i use multiple outer join on one table. I'm using ORACLE 8.1.6.
I know this version of oracle doesnt support this. But is there anmy other wa\y I can achieve this.
Thanks amd Regards
Deependra

Tricky question - but I went through this about 3 months ago, and found a good thread on here that explains it pretty well.
check out Re: Outer join a table with two diff table
You basically will have to create an inline view with one outer join in there, and then a second outer join on the outside. Read through the posts in that thread and it should help!

Similar Messages

  • Query with multiple outer joins

    I had a doubt with whether the following kind of query is valid with multiple outer-joins. The format of the query is something like this:-
    select A.col1, B.col2
    from table1 A, table2 B, table3 C where
    A.col3=B.col4(+) and B.col5=C.col6(+)
    This would mean the follwoing with regard to outer-joins in the query.
    1) fetch records with col3 in table A matching or not matching col4 in table B
    2) fetch records with col5 in table B matching or not matching col6 in table C
    So, this query is valid?
    I hope, my question is clear.
    Please, help in solving the doubt.
    regards

    This is valid and it works fine

  • Multiple LEFT OUTER JOIN on Oracle 8i

    Hi,
    I have to convert some stored procedure from Sql Server to Oracle 8i where I have multiple LEFT OUTER JOIN on a table. Because Oracle 8i accept only one outer join on a table how can I convert this:
    select a.id, b.id
    from test as a LEFT JOIN test1 b ON a.id(+)=b.id
    and c.display(+)=b.display
    and c.name(+)='Done';
    Thanks.

    Rewrite as:
    select a.id, b.id
    from test, test1 b
    WHERE a.id(+)=b.id
    and a.display(+)=b.display
    and a.name(+)='Done';
    Though I would lose the (+) in a.name(+) = 'Done' unless you want every name.

  • Help with outer joins in Oracle!!

    so far this is what i've come up with and the code below does not work. Can anyone please help me on how the sytanx of left joins and how to use multiple left joins in a single query in oracle?
    SELECT a.*, b.Position_CD, c.Skill_CD, d.Team_Name, d.Team_Country, d.Club, e.Structure_Name
    FROM Roster a, Roster_position b, roster_skill c, Team d, Team_Structure e
    where (a.Roster_ID = ((b.Roster_ID= c.Roster_Id(+)) b.roster_id(+)).......
    I dont' know how to add more left joins!
    Here is the query I'm trying to duplicate (which is a query from Ms Access databaase which works fine).
    SELECT a.*, b.Position_CD, c.Skill_CD, d.Team_Name, d.Team_Country, d.Club, e.Structure_Name
    from ((Roster a LEFT JOIN (Roster_Position b LEFT JOIN Roster_Skill c ON b.Roster_ID=c.Roster_ID) ON a.Roster_ID=b.Roster_ID) LEFT JOIN Team d ON a.Team_CD=d.Team_CD) LEFT JOIN Team_Structure e ON a.Team_Structure_CD=e.Team_Structure_CD
    ORDER BY a.Roster_Id;
    Any help or comments are greatly appreciated

    First,
    I am not one of the leading SQL brains here...but I'm taking a stab, nonetheless.
    Second,
    Here's my best guess - and it seems to me that it should work as there are not two outer joins between any two tables. I hope I decoded your joins correctly - quite a mess that Access syntax!
    SELECT a.*, b.position_cd, c.skill_cd, d.team_name, d.team_country, d.club, e.structure_name
    FROM ROSTER a, ROSTER_POSITION b, ROSTER_SKILL c, TEAM d, TEAM_STRUCTURE e
    WHERE a.roster_id = b.roster_id(+)
    AND b.roster_id = c.roster_id(+)
    AND a.team_cd = d.team_cd(+)
    AND a.team_structure = e.team_structure(+);Third,
    As an architect-dude, it seems to me that you have a serious
    modeling problem to need so many outer joins in such a basic
    grab of data. In any scale other than minute, the performance
    of this model will suffer dramatically. Specifically, why can't
    ROSTER have an equijoin with TEAM and with TEAM_STRUCTURE - as they
    appear to be lookup tables...
    Good Luck
    (I'm certain you'll get better SQL from the others),
    Michael O'Neill
    Publisher of the PigiWiki
    clever-idea.com

  • How to use OUTER JOIN in Oracle Answers Filters?

    Hi, I need to have a filter on an 'Oracle Answers' report.
    The query from the NQQuery.log appears as below. (I have simplified the SELECT clause here for easy reading)
    SELECT t692.enquiry_business_route AS c1,
    t692.enquiry_id AS c11, t913.YEAR AS c12,
    t913.full_date AS c13, t666.surname AS c14,
    t666.post_code AS c15, t855.company_name AS c16,
    t983.notes AS c30
    FROM
    mkt_dw_enev_enhi_dim t983,
    mkt_dw_key_partner_dim t855,
    mkt_dw_event_type_dim t821,
    mkt_dw_customer_dim t666,
    mkt_dw_time_dim t913,
    mkt_dw_enquiry_event_fact t692
    WHERE (
    t692.enquiry_id = t983.enqu_id
    AND t666.customer_dim_key = t692.customer_dim_key
    AND t692.event_date_time_key = t913.time_dim_key
    AND TRUNC(t983.event_date)= t913.FULL_DATE
    AND t692.event_type = t821.event_type_dim_key
    AND t692.key_partner_dim_key = t855.key_partner_dim_key
    AND t821.event_type_category = 'RECEIVE_FEE'
    AND t913.YEAR = 2009
    and t692.enquiry_id = 535986
    For the following two lines I would like to have the OUTER JOIN.
    AND t692.event_type = t821.event_type_dim_key(+)
    AND t821.event_type_category(+) = 'RECEIVE_FEE' (THIS IS THE FILTER CONDITION, AT THE MOMENT IT DOESN'T WORK WITH OUTER JOIN SYMBOL)
    Please could you let me know the best way of achieving the above.
    Thanks
    Srikanth

    In the BMM layer in the join condition you will be able to specify the join to be (left, right or full outer join).
    You can even add the required table in the LTS(logical table source) and also specify a left, right or full outer join there as well.
    There is an interesting work around as mentioned in the below blog to get to the Outer join results with out changing anything in rpd but in Answers.
    http://obiee101.blogspot.com/2008/11/obiee-outerjoin-workaround.html
    Hope it helps
    Thanks
    prash

  • Outer Joins in Oracle 9i

    Post Author: wtfinc
    CA Forum: Data Connectivity and SQL
    After upgrading to Oracle 9i, the SQL queries generated by Crystal Reports XI contain a syntax errors when performing Outer Joins.  The particular error returned by Oracle is "Old Style Outer Join can not be used with ANSI Joins".  Does anyone know a work around short of changing the datbase connection to a command and rewriting the report?

    Post Author: Jagan
    CA Forum: Data Connectivity and SQL
    If you choose SQL Query from Crystal's Database menu, does the SQL have a combination of old and new syntax?

  • Outer join with Oracle Syntax

    Hi, i'm new in oracle and ihave been working this query for reports for about 2 weeks, plz take a look on my query
    SELECT mmt.transaction_date "Transaction Date",
                msib.segment1 "Item",
                gcc.segment1||'-'||gcc.segment2||'-'||gcc.segment3||'-'||gcc.segment4||'-'||gcc.segment5||'-'||gcc.segment6||'-'||(nvl(gcc.segment7,'000000')) "account",
                (CASE mttype.transaction_type_name
                WHEN 'Average cost update' THEN
              ((nvl(mmt.new_cost,0) - nvl(mmt.prior_cost,0)) * nvl(mmt.quantity_adjusted,0)) + nvl(mmt.variance_amount,0)
                ELSE
                 (mmt.Primary_quantity * nvl(mmt.actual_cost, 0) + nvl(mmt.variance_amount, 0))
               END) "Transaction Value",
                mttype.description "Transaction Type",
                mmt.subinventory_code "Subinventory",
                ood.organization_code "Org",
                msib.Primary_UOM_Code "UOM",
                mmt.Primary_Quantity "Primary Quantity",
                mtr.description "Reason",
                mmt.transaction_reference "Reference"
    FROM mtl_material_transactions mmt,
             mtl_system_items_b msib,
             mtl_transaction_accounts mta,
             gl_code_combinations gcc,
             mtl_transaction_types mttype,
             Org_Organization_Definitions ood,
             mtl_transaction_reasons mtr
    WHERE mmt.transaction_date >= :P_DATE_FROM
               and mmt.transaction_date  < :P_DATE_TO +1
               and mmt.organization_id = :P_ORGANIZATION
               and msib.organization_ID = mmt.organization_ID 
               and msib.inventory_item_id=mmt.inventory_item_id
               and mta.transaction_id=mmt.transaction_id
               and gcc.code_combination_id = mta.reference_account
               and mttype.transaction_type_id=mmt.transaction_type_id
               and mmt.reason_id=mtr.reason_id(+)
               and ood.organization_id=mmt.organization_id
               and mttype.transaction_type_id = :P_TRANSACTION_TYPE
               and msib.segment1 = :P_ITEM
               AND gcc.segment2 = :P_ACCOUNTthe null values is on the mtl_material_transactions table, which is reason_id, subinventory_code, and transaction_reference
    the desired out put would be to show all the record on mtl_material_transactions with the null values
    so, did i put the right symbol for the outer join ??
    btw
    i have tried put the (+) on various places but it still no good, and i'm really at a loss

    user11174063 wrote:
    Hi, i'm new in oracle and ihave been working this query for reports for about 2 weeks, plz take a look on my query
    SELECT mmt.transaction_date "Transaction Date",
    msib.segment1 "Item",
    gcc.segment1||'-'||gcc.segment2||'-'||gcc.segment3||'-'||gcc.segment4||'-'||gcc.segment5||'-'||gcc.segment6||'-'||(nvl(gcc.segment7,'000000')) "account",
    (CASE mttype.transaction_type_name
    WHEN 'Average cost update' THEN
    ((nvl(mmt.new_cost,0) - nvl(mmt.prior_cost,0)) * nvl(mmt.quantity_adjusted,0)) + nvl(mmt.variance_amount,0)
    ELSE
    (mmt.Primary_quantity * nvl(mmt.actual_cost, 0) + nvl(mmt.variance_amount, 0))
    END) "Transaction Value",
    mttype.description "Transaction Type",
    mmt.subinventory_code "Subinventory",
    ood.organization_code "Org",
    msib.Primary_UOM_Code "UOM",
    mmt.Primary_Quantity "Primary Quantity",
    mtr.description "Reason",
    mmt.transaction_reference "Reference"
    FROM mtl_material_transactions mmt,
    mtl_system_items_b msib,
    mtl_transaction_accounts mta,
    gl_code_combinations gcc,
    mtl_transaction_types mttype,
    Org_Organization_Definitions ood,
    mtl_transaction_reasons mtr
    WHERE mmt.transaction_date >= :P_DATE_FROM
    and mmt.transaction_date  < :P_DATE_TO +1
    and mmt.organization_id = :P_ORGANIZATION
    and msib.organization_ID = mmt.organization_ID 
    and msib.inventory_item_id=mmt.inventory_item_id
    and mta.transaction_id=mmt.transaction_id
    and gcc.code_combination_id = mta.reference_account
    and mttype.transaction_type_id=mmt.transaction_type_id
    and mmt.reason_id=mtr.reason_id(+)
    and ood.organization_id=mmt.organization_id
    and mttype.transaction_type_id = :P_TRANSACTION_TYPE
    and msib.segment1 = :P_ITEM
    AND gcc.segment2 = :P_ACCOUNTthe null values is on the mtl_material_transactions table, which is reason_id, subinventory_code, and transaction_reference
    the desired out put would be to show all the record on mtl_material_transactions with the null values
    so, did i put the right symbol for the outer join ??
    btw
    i have tried put the (+) on various places but it still no good, and i'm really at a losshttp://www.lmgtfy.com/?q=oracle+outer+join+example

  • Outer join syntax - oracle 8i

    Here is an Oracle 8i issue I've run into ....
    I am trying to create a table that contains a record for each hour of the day (even if count is 0). I have a problem when I try a right outer join using the following syntax:
    SELECT MDT.date_field, COUNT(*)
    FROM MASTER_DATE_TABLE MDT, hsa_tgt.PICIS_OR POR
    WHERE MDT.date_field = TO_CHAR(POR.OR_IN_DTTM,'YYYYMMDDHH24') (+)
    AND TO_DATE(MDT.date_field,'YYYYMMDDHH24') >= '01-Jan-2006'
    AND TO_DATE(MDT.date_field,'YYYYMMDDHH24') <= '31-Jan-2006'
    GROUP BY MDT.date_field;
    The problem 'SQL code no properly ended' only occurs if I use the TO_CHAR function (or any function for that matter) on the outer join line.
    Is there a workaround? I did manage to create a temporary table and then successfully do an outer join in order to bypass having the to_char function in the join statement.
    Maybe a union?
    TIA

    I had to put it in a subquery? (if that's what it's called)
    SELECT a1.date_field DateAndHour, b1.OR_date, NVL(b1.record_count,0)
    FROM  MASTER_DATE_TABLE a1,
                  (SELECT TO_CHAR(b.OR_IN_DTTM,'YYYYMMDDHH24') OR_date, COUNT(*) record_count
                FROM hsa_tgt.PICIS_OR b
                GROUP BY TO_CHAR(b.OR_IN_DTTM,'YYYYMMDDHH24')) b1
    WHERE a1.date_field  = b1.OR_date (+)
    GROUP BY a1.date_field, b1.OR_date, b1.record_count
    HAVING (TO_DATE(a1.date_field,'YYYYMMDDHH24') BETWEEN '01-Jan-2006' AND '31-Jan-2006')
    ORDER BY a1.date_field;

  • How to use multiple outer join in ODI

    SELECT
    Count(*)
    FROM
    student S,
    department D,
    course C
    WHERE
    D.S_Name=S.S_Name
    AND D.Dept_Name = C.Dept_Name (+)
    and S.C_Name =C.C_Name (+)
    And (D.Dept_ID = 1);
    I run this query. I got an ORA-01417 error.

    In topology change the join option to Ordered ISO
    then rewrite your query with ANSI syntax.
    SELECT
    Count(*)
    FROM
    student S join department D on D.S_Name=S.S_Name,
    student S right outer join course C on S.C_Name =C.C_Name,
    department D right outer join course C on S.C_Name =C.C_Name
    where
    (D.Dept_ID = 1);
    First verify the code in sql client befor implementing it in ODI
    Thanks,
    Sutirtha

  • Left Outer Joins in Oracle 9

    Hello everybody, I am kinda new to SQL.
    There is only one Primary key for our database. For example 'ID'. Somebody had this code in the WHERE clause code before I started working on this. Do we really need to use the LEFT OUTER JOIN (+) in order to bring all the records. If I remove the join the number of records are reduced to a 1/6th of the original (with the joins). Please help me
    EMPLOYEE.ID = ADDRESS.ID (+) AND
    EMPLOYEE.ID = PAYROLL.ID (+) AND
    EMPLOYEE.ID = USERS.ID (+) AND
    EMPLOYEE.ID = DEPARTMENT.ID (+)

    If you want a row in the result for every row in the employee table, whether there is a matching row in the address, payroll, users, or department table, then yes, you need the outer join. If you only want results where there are matching rows in each of the detail tables, then you don't need the outer joins.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Multiple outer joins from a single table

    Here is my scenario - I have 3 folders:
    Theater - contains Theater Name and Theater ID
    Agency - contains Agency Name and Theater ID
    Depot - contains Depot Name and Theater ID
    A theater may or may not have an agency. Likewise, it may or may not have a depot.
    Thus, I've set up a join from Theater (master) to Agency on Theater ID, and selected "outer join on detail"
    Likewise, I've done the same between Theater (master) and Depot on Theater ID
    When I attempt to create a report with the columns Theater Name, Agency Name, and Depot Name, I am unable to do so. I can only pick either Agency Name or Depot Name, not both. When I try to add the second outer joined element, Discoverer reports that it cannot determine the join configuration because "more than 1 of the detail folders uses non-aggregate items"
    What am I doing wrong? Any help would be greatly appreciated, thanks!

    Hi,
    Try change the joins to be "outer join on detail" and "one to one join relationship between master and detail".
    Hope that helps,
    Rod West

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

  • Can anyone tell me WHY Oracle won't allow sub-queries in outer joins?

    Hi,
    I've recently been tasked with converting a series of InterBase dbs to Oracle.
    Many of the queries in the InterBase dbs use sub-queries in outer joins. Oracle won't countenance this (01799 - a column may not be outer-joined to a subquery).
    I can get around it using functions but WHY won't Oracle allow this?
    SQL Server allows it, InterBase allows it (I don't know about ANSI SQL) but it seems to be a common enough technique...
    I'm just curious (and also a little frustrated!).
    Thanks in advance,,,

    Hi,
    >>Oracle treat an empty string as a NULL
    Well, you same answer your question. Because it is empty
    SGMS@ORACLE10> create table tab (cod number, name varchar2(1));
    Table created.
    SGMS@ORACLE10> insert into tab values (1,'');
    1 row created.
    SGMS@ORACLE10> insert into tab values (2,' ');
    1 row created.
    SGMS@ORACLE10> commit;
    SGMS@ORACLE10> select cod,dump(name) from tab;
           COD DUMP(NAME)
             1 NULL
             2 Typ=1 Len=1: 32
    SGMS@ORACLE10> select * from tab where name is null;
           COD NAME
             1Cheers
    If you talking about language tools, for example PHP treat empty string <> of NULL values. e.g: functions like is_empty() and is_null()
    Message was edited by:
    Legatti

  • Outer Join with an 'OR'

    I have a very complicated query to construct that requires the use of 'AND', 'OR', and Outer Joins. Oracle's 9i documentation says you can't use an outer join with an 'OR'.
    Can you suggest how I may return the correct records under the following conditions. There are 3 tables to join. Table A, Table B, and Table C. Tables A & B join with an = to common fields. The problem is with Table C.
    The way the application was designed, it has to track a parent and child relationship. As such, the field to relate may exist in 1 of 2 fields. Let's see if I can draw it out for you.
    Table A - Record 1
    (ID = 1)
    Table B - Record 1
    (ID =1 [this relates to Table A.ID]
    PID = 12345
    CID = 67899
    Site = A)
    Table C - Record 1
    (PID = 12345 [this relates to Table B.PID]
    CID = 67899
    Site = A)
    Table C - Record 2
    (PID = 67899 [This relates to Table B.CID]
    CID = 12345
    Site = A)
    Now, I need to relate Table A to Table B where A.ID = B.ID AND
    ((B.PID = C.PID AND B.CID = C.CID)
    OR
    (B.CID = C.PID AND B.PID = C.CID))
    AND
    B.SITE = C.SITE
    There may or may NOT be related records in Table C. That's the problem. This is where I need the outer join to get the all the records of the 1st two joins and only those that apply from the last join.
    Your help will be greatly appreciated.

    I'd create two queries, a join from b to c in each of those manners and then UNION ALL the results together.
    drop table junk_a;
    create table junk_a (
      id number );
    drop table junk_b;
    create table junk_b (
      id number,
      pid number,
      cid number,
      site varchar2(80) );
    drop table junk_c;
    create table junk_c (
      pid  number,
      cid  number,
      site  varchar2(80) );
    insert into junk_a values (1);
    insert into junk_b values (1, 12345, 67899, 'A');
    insert into junk_c values (12345, 67899, 'A');
    insert into junk_c values (67899, 12345, 'A');
    commit;
    SELECT b.*,
           c.site AS site_c
      FROM junk_b b,
           junk_c c
    WHERE c.pid(+) = b.pid
       AND c.cid(+) = b.cid
    UNION ALL
    SELECT b.*,
           c.site AS site_c
      FROM junk_b b,
           junk_c c
    WHERE c.cid(+) = b.pid
       AND c.pid(+) = b.cid;
    SELECT a.id,
           bc.pid,
           bc.cid,
           bc.site,
           bc.site_c
      FROM junk_a  a,
    SELECT b.*,
           c.site AS site_c
      FROM junk_b b,
           junk_c c
    WHERE c.pid(+) = b.pid
       AND c.cid(+) = b.cid
    UNION ALL
    SELECT b.*,
           c.site AS site_c
      FROM junk_b b,
           junk_c c
    WHERE c.cid(+) = b.pid
       AND c.pid(+) = b.cid
           )  bc
    WHERE bc.id(+) = a.id;

  • Outer join on query with OR clause

    hi all, i am having problem outerjoining a query with or clause
    here is my data
    WITH table1 AS
    SELECT  'test' txt1, 'pak' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL
    SELECT  null txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL
    SELECT  null txt1, NULL txt2, 'ced3' txt3, 'su3' txt4 FROM dual UNION ALL
    SELECT  null txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
    SELECT  'text5' txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
    SELECT  null txt1, NULL txt2, null txt3, null txt4 FROM dual
    ,table2 AS
    SELECT 111 pid, 'test' txt1, 'pak4' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL
    SELECT 222 pid, 'test1' txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL
    SELECT 333 pid, 'test2' txt1, 'pak3' txt2, 'ced3' txt3, 'su4' txt4 FROM dual UNION ALL
      SELECT 444 pid, 'test2' txt1, 'pak3' txt2, 'ced4' txt3, 'su3' txt4 FROM dual
    SELECT b.pid, a.*
    from table1 a, table2 b
    WHERE (a.txt1 = b.txt1 OR
           a.txt1 IS NULL AND a.txt2=b.txt2 OR
           Nvl(a.txt2, a.txt1) IS NULL AND a.txt3 = b.txt3 OR
           Nvl(a.txt2, a.txt1) IS NULL  AND a.txt3 IS NULL AND a.txt4 = b.txt4
           ) as you can see i am joining table1 and table 2. i am joining with txt1, if txt1 is null then join by txt2, if null then join by txt3 and so on.
    the code above product this output
    PID     TXT1     TXT2     TXT3     TXT4
    ===     ====     ===   ==== ====
    111     test     pak      ced     su
    222             pak      ced2     su2
    333                     ced3     su3
    444                          su3this output is partially correct. only 4 rows were display and two was left out
    SELECT  'text5' txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
    SELECT  null txt1, NULL txt2, null txt3, null txt4 FROM dual i tried using outer join but oracle complain that i cannot use outerjoin with OR clause.
    can someone help modify my query to display the output below ?
    PID     TXT1     TXT2     TXT3     TXT4
    ===    ====      ===   ====  ====
    111     test     pak      ced     su
    222             pak      ced2     su2
    333                     ced3     su3
    444                          su3
    NULL  NULL   NULL    NULL   NULL
         test5

    Not sure you can do it with the Oracle style outer joins, but wioth ANSI style joins it is simple, actually exactly as you had it.
    SQL> set null null;
    SQL> WITH table1 AS (
      2   SELECT  'test' txt1, 'pak' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL
      3   SELECT  null txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL
      4   SELECT  null txt1, NULL txt2, 'ced3' txt3, 'su3' txt4 FROM dual UNION ALL
      5   SELECT  null txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
      6   SELECT  'text5' txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
      7   SELECT  null txt1, NULL txt2, null txt3, null txt4 FROM dual),
      8  table2 AS (
      9   SELECT 111 pid, 'test' txt1, 'pak4' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL
    10   SELECT 222 pid, 'test1' txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL
    11   SELECT 333 pid, 'test2' txt1, 'pak3' txt2, 'ced3' txt3, 'su4' txt4 FROM dual UNION ALL
    12   SELECT 444 pid, 'test2' txt1, 'pak3' txt2, 'ced4' txt3, 'su3' txt4 FROM dual)
    13  SELECT b.pid, a.*
    14  from table1 a
    15     LEFT JOIN table2 b
    16        ON (a.txt1 = b.txt1 OR
    17            a.txt1 IS NULL AND a.txt2=b.txt2 OR
    18            Nvl(a.txt2, a.txt1) IS NULL AND a.txt3 = b.txt3 OR
    19            Nvl(a.txt2, a.txt1) IS NULL  AND a.txt3 IS NULL AND a.txt4 = b.txt4);
           PID TXT1   TXT2   TXT3   TXT4
           111 test   pak    ced    su
           222 null   pak    ced2   su2
           333 null   null   ced3   su3
           444 null   null   null   su3
    null       text5  null   null   su3
    null       null   null   null   nullJohn

Maybe you are looking for

  • How to use the updated value in the same update statement

    Hello, I just wonder how to use the updated new value of other column in the same udpate statement. I am using Oracle 11.2, and want to update the two columns with one update statement as following: create table tb_test (id number(5), tot number(5),

  • Performance: Mathematical functions

    I'm a recent convert to Oracle and need some advice. Scenario: 1. Our client has a web application written in Java that queries an Oracle database to extract a list of stores based on their location. 2. The client approached us to rewrite the applica

  • Accessibility Alt Text problem

    I have an acronym in the PDF and want to create alternate text for it. I believe I understand the procedure to do so. I'm using the Read Out Loud feature in Acrobat Pro 9 to test it. The reader reads the alternate text first , but then it also reads

  • How to use "Context Menu" web item in WAD 7.0 ?

    Hi Experts, Kindly tell me How to use "Context Menu" Web item in SAP WAD 7.0 ? How to attach this Web item to my Graph/Chart ? Plz provide some documents on this. Full points will be given. Thanks. -Jay Jay Edited by: jayaprakash j on Oct 10, 2008 1:

  • How to view what is using up the temporary tablespace

    Hi all I am running into a problem - my temporary tablespace is being completely used up. How would i find out what is using up this? Technically it has enough space to function properly but now we are getting 0 bytes free. thanks!