Oracle 8i Full Outer Join Syntax

Can someone please help me run this on Oracle 8i:
SELECT
R.CUSTOMER_NUM,
R.SURNAME_NM,
R.FIRST_NM,
R.STREET_NM,
R.PROV_CD,
R.CITY_NM,
R.POSTL_CD,
W.ADDR_TWO_DESC,
C.RTL_CO_NUM,
C.CARD_NUM
FROM
RTL_CUST R
FULL OUTER JOIN WHLSL_CUST W ON (R.CUST_NUM = W.CUST_NUM)
FULL OUTER JOIN CUSTOMER_CARD C ON (T.CUST_NUM = C.CUST_NUM)
I only know the ANSI syntax. Whats the old one?

Is this correct:
SELECT R.CUST_NUM, R.SURNAME_NM, R.FIRST_NM, R.STREET_NM, R.PROV_CD, R.CITY_NM, R.POSTL_CD, W.ADDR_TWO_DESC, NULL AS RTL_CO_NUM, NULL AS CARD_NUM
FROM CCD_RTL_CUST R, CCD_WHLSL_CUST W WHERE R.CUST_NUM (+) = W.CUST_NUM
UNION
SELECT R.CUST_NUM, R.SURNAME_NM, R.FIRST_NM, R.STREET_NM, R.PROV_CD, R.CITY_NM, R.POSTL_CD, W.ADDR_TWO_DESC, NULL AS RTL_CO_NUM, NULL AS CARD_NUM
FROM CCD_RTL_CUST R, CCD_WHLSL_CUST W WHERE R.CUST_NUM = W.CUST_NUM (+)
UNION
SELECT R.CUST_NUM, R.SURNAME_NM, R.FIRST_NM, R.STREET_NM, R.PROV_CD, R.CITY_NM, R.POSTL_CD, NULL AS ADDR_TWO_DESC, C.RTL_CO_NUM, C.CARD_NUM
FROM CCD_RTL_CUST R, CUST_CARD C WHERE R.CUST_NUM (+) = C.CUST_NUM
UNION
SELECT R.CUST_NUM, R.SURNAME_NM, R.FIRST_NM, R.STREET_NM, R.PROV_CD, R.CITY_NM, R.POSTL_CD, NULL AS , C.RTL_CO_NUM, C.CARD_NUM
FROM CCD_RTL_CUST R, CUST_CARD C WHERE R.CUST_NUM = C.CUST_NUM (+);

Similar Messages

  • Query with FULL OUTER JOIN , help pleaseeeeeeeeeeee...

    Hi everyone,
    I'm trying to write a query for a report in Oracle SQL, but i just can't figure out how to do it.
    I'm using Oracle 10g release 1.0 database and i execute my queris in SQL* PLUS ( eventually i'm gonna use them in Oracle Report Builder ) .
    here's what i have:
    i have four tables that are used for our inventory application. lets call them INCOMMING , INCOMMING_ITEMS , OUTGOING , OUTGOING_ITEMS.
    as you may have guessed , INCOMMING_ITEMS is the detail table for INCOMMING ( joined by IID column) and also OUTGOING_ITEMS is the detail table for OUTGOING ( joined by OID column ).
    here is the structure of them :
    INCOMMING
    IID varchar2
    CDATE date
    INCOMMING_ITEM
    IID varchar2
    PART_NO number
    QTY number
    OUTGOING
    OID varchar2
    CDATE date
    OUTGOING_ITEM
    OID varchar2
    PART_NO number
    QTY number
    now , the query i want, should return part_no , cdate , sum of OUTGOING qty , sum of INCOMMING qty .
    the result of the query should be sth like this :
    part_no     cdate     O_qty     I_qty
    100     01/05/06     10     0
    100     01/05/07     20     60
    200     01/06/02     0     50
    300     01/06/02     30     40
    this means that for some dates and for some parts, i may not have INCOMMING or OUTGOING data, but if at least one of the 2 last columns has a non-zero data, i should show the row ( like the first and third rows of my example result), and if both have data for the same PART_NO and the same CDATE, both should be showed in the same row. ( like the second row in my example result)
    i tried so much and came up with several huge and also time consuming queries, but then i read abt FULL OUTER JOIN somewhere and tried using that. here is what i came up with :
    SELECT
    PART_NO , CDATE , sum(II.QTY) I_QTY , SUM (OI.QTY) O_QTY
    FROM
         (OUTGOING O INNER JOIN OUTGOING_ITEM OI USING ( OID ) )
    FULL OUTER JOIN
         (INCOMMING I INNER JOIN INCOMMING_ITEM II USING ( IID ) )
    ON ( I.CDATE = O.CDATE AND II.PART_NO = OI.PART_NO)
    WHERE
    I.CDATE = :PARAMETER1
    AND O.CDATE = :PARAMETER1
    GROUP BY
    PART_NO , CDATE
    this query is short and fast , but the results r not what i expected. i mean, although i have used FULL OUTER JOIN in the query , but the results i get r sth like this :
    part_no     cdate     O_qty     I_qty
    100     01/05/07     20     60
    300     01/06/02     30     40
    which means only the rows that has both values are returned.
    any change i make to this query would make the SQL* PLUS hang , like when i use the cartesian product of two large tables, so i guess my changes wheren't in the right direction.
    i think its possible to write this query using FULL OUTER JOIN syntax, but i just can't find it.
    Can anybody pleaseeeeeeeeeeeee help me?
    thanx in advance,
    Maryam.

    Note: I wrote this on the fly -- hope there is no syntax errors, otherwise forgive me -- but you get the idea..
    select
    fromUnionAll.cdate, fromUnionAll.part_no,
    sum(fromUnionAll.O_qty) O_qty,
    sum(fromUnionAll.I_qty) I_qty
    from
    select
    iinner.cdate, iinner.part_no, 0 O_qty, iinner.I_qty
    from
    select
    i.cdate, ii.part_no,
    /* added the case only for the extreme case when there is
    no record anywhere for the given CDATE in INCOMMING_item */
    sum( ( case when ii.qty is not null then ii.qty else 0 end) ) I_qty
    from
    incomming i,
    incomming_item ii
    where
    i.iid = ii.iid (+)
    group by i.cdate, ii.part_no
    ) iinner
    union all
    select
    oinner.cdate, oinner.part_no, oinner.O_qty, 0 I_qty
    from
    select
    o.cdate, oi.part_no,
    /* added the case only for the extreme case when there is
    no record anywhere for the given CDATE in OUTGOING_item */
    sum( ( case when oi.qty is not null then oi.qty else 0 end) ) O_qty
    from
    outgoing o,
    outgoing_item oi
    where
    o.oid = oi.oid (+)
    group by o.cdate, oi.part_no
    ) oinner
    ) fromUnionAll
    group by fromUnionAll.cdate, fromUnionAll.part_no;
    --Samson                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Ora-22905:cannot access rows from a non-nested ...(during full outer join)

    Greetings Gurus,
    I'm getting an ORA-22905 when I try and do a full outer join in the following function. If I include the commented lines in the perstren_diff_recs2 function I get the error. Both halfs of the union query work by themselves. When I union them bam error. Also, when I use the full outer join syntax the Oracle session craps the bed with a end of file communication error. That is why I'm using the simulated full outer join.
    My goal was to abstract the XML in my queries. The results from the pipelined function is a delta between what is in the XML document and a relational base table.
    Derrick
    CREATE OR REPLACE PACKAGE XML_UTILS is
    TYPE perstren_typ is record (
    uic varchar2(6),
    tpers varchar2(2),
    deply varchar2(6),
    secur varchar2(1),
    struc number(4),
    auth number(4)
    TYPE perstren_diff_typ is record (
    uic           varchar2(6),
    transaction_type char(1),
    tpers           varchar2(2),
    deply           varchar2(6),
    secur           varchar2(1),
    struc           number(4),
    auth           number(4)
    TYPE perstrenSet is table of perstren_typ;
    TYPE perstrenDiffSet is table of perstren_diff_typ;
    function perstren_recs (uic varchar2) return perstrenSet pipelined;
    function perstren_diff_recs2 (uic varchar2) return perstrenDiffSet pipelined;
    end;
    CREATE OR REPLACE PACKAGE BODY XML_UTILS is
    function perstren_diff_recs2 (uic varchar2) return perstrenDiffSet pipelined is
    cursor perstren_recs_cur(in_uic varchar2) is
    select p.uic, p.tpers, p.deply, P.secur, p.struc,p.auth,
    doc.uic as xmluic,
    doc.tpers as xmltpers,
    doc.deply as xmldeply,
    doc.secur as xmlsecur,
    doc.struc as xmlstruc,
    doc.auth as xmlauth
    from perstren_bac p left outer join
    table(xml_utils.perstren_recs(in_uic)) doc
    on (p.uic = doc.uic and
    p.tpers = doc.tpers and
    p.deply = doc.deply)
    where p.uic = in_uic;
    -- union
    -- select p.uic, p.tpers, p.deply, P.secur, p.struc,p.auth,
    -- doc.uic as xmluic,
    -- doc.tpers as xmltpers,
    -- doc.deply as xmldeply,
    -- doc.secur as xmlsecur,
    -- doc.struc as xmlstruc,
    -- doc.auth as xmlauth
    -- from perstren_bac p right outer join
    -- table(xml_utils.perstren_recs(in_uic)) doc
    -- on (p.uic = doc.uic and
    -- p.tpers = doc.tpers and
    -- p.deply = doc.deply)
    -- where doc.uic = in_uic;
    out_rec perstren_diff_typ;
    begin
    for cur_rec in perstren_recs_cur(uic) loop
    if cur_rec.xmldeply is not null and cur_rec.xmltpers is not null then
    out_rec.uic := cur_rec.xmluic;
    out_rec.tpers := cur_rec.xmltpers;
    out_rec.deply := cur_rec.xmldeply;
    out_rec.secur := cur_rec.xmlsecur;
    out_rec.struc := cur_rec.xmlstruc;
    out_rec.auth := cur_rec.xmlauth;
    else
    out_rec.uic := cur_rec.uic;
    out_rec.tpers := cur_rec.tpers;
    out_rec.deply := cur_rec.deply;
    out_rec.secur := cur_rec.secur;
    out_rec.struc := cur_rec.struc;
    out_rec.auth := cur_rec.auth;
    end if;
    if cur_rec.uic is not null and cur_rec.xmldeply is not null and cur_rec.xmltpers is not null and (
    nvl(cur_rec.secur,'XX') != nvl(cur_rec.xmlsecur,'XX') or
    nvl(cur_rec.struc,9999) != nvl(cur_rec.xmlstruc,9999) or
    nvl(cur_rec.auth,9999) != nvl(cur_rec.xmlauth,9999)) then
    out_rec.transaction_type :='U';
    elsif cur_rec.uic is null and cur_rec.xmldeply is not null then
    out_rec.transaction_type :='I';
    elsif cur_rec.uic is not null and cur_rec.xmldeply is null then
    out_rec.transaction_type :='D';
    else
    out_rec.transaction_type :='O';
    end if;
    PIPE row (out_rec);
    end loop;
    exception
    when others then
    if perstren_recs_cur%isopen then
    close perstren_recs_cur;
    end if;
    raise;
    return;
    end;
    function perstren_recs (uic varchar2) return perstrenSet pipelined is
    cursor perstren_recs_cur(in_uic varchar2) is
    select uic,
    extractvalue(Column_value,'/PERSTREN/TPERS') as TPERS,
    extractvalue(Column_value,'/PERSTREN/DEPLY') as DEPLY,
    extractvalue(Column_value,'/PERSTREN/SECUR') as SECUR,
    extractvalue(Column_value,'/PERSTREN/STRUC') as STRUC,
    extractvalue(Column_value,'/PERSTREN/AUTH') as AUTH
    from test_ref ref,
    table(XMLSequence(extract(ref.XML_DOC,'/RasDataSet/PerstrenList/PERSTREN'))) per
    where ref.uic = in_uic;
    out_rec perstren_typ;
    begin
    open perstren_recs_cur(uic);
    loop
    fetch perstren_recs_cur into out_rec;
    exit when not perstren_recs_cur%FOUND;
    PIPE row (out_rec);
    end loop;
    close perstren_recs_cur;
    exception
    when others then
    if perstren_recs_cur%isopen then
    close perstren_recs_cur;
    end if;
    raise;
    return;
    end;
    end;

    Oracle bug when executing the query in a function

  • Outer Join Syntax in sql2k to Oracle Migration

    All of my existing SQL Server 2000 code is using the (INNER, LEFT OUTER, RIGHT OUTER) JOIN syntax which according to Oracle SQL Reference (A90125-01) is supported. The migration workbench seems to want to convert this to the old style syntax of putting (+) in the where clause conditions. I am therefore getting lots of warnings telling me that "complex outer joins are not reliably supported". Is there a setting somewhere that will tell the migration workbench to maintain (subject to required conversion) the original syntax format.

    Hi Doug,
    The issue you report has been tackled in a recent internal build released by the OMWB team. OMWB version 9.2.0.1.6 which is freely downloadable on the http:\\mtg.ie.oracle.com site. As I've mentioned, this is an internal release and is therefore not supported - although it is very stable and has already been used by several internal customers. We expect to have a fully supported release of OMWB available on OTN in December.
    In version 9.2.0.1.6, there is an option in the "Parse Options" tab on the Stored Procedures property sheet called "Generate Oracle 8i Outer Joins" - this setting is switched off by default in this build and would therefore preserve your ANSI compliant joins by default. Switching the setting on causes the OMWB parser to generate the joins in the old (+) Oracle syntax standard.
    I hope this helps,
    Tom.

  • Diff "full outer join" va. "(+)" SELECT syntax ?

    As far as I know there are two ways of defining an outer join:
    Select ... from tab1 t1 full outer join tab2 t2 on t1.id =t2.id;
    or:
    Select ... from tab1 t1, tab2 t2 where t1.id = t2.id(+)
    Are they absolutely equivialent?
    Which are the most common one?
    Which are used on other databases (DB2, MySQL) as well?
    Can I put an additional WHERE clause at the end in the first statement:
    Select ... from tab1 t1 full outer join tab2 t2 on t1.id =t2.id WHERE .....;

    Select ... from tab1 t1 full outer join tab2 t2 on t1.id =t2.id;This is FULL OUTER JOIN
    Select ... from tab1 t1, tab2 t2 where t1.id = t2.id(+)This is LEFT OUTER JOIN.
    They are entirely different.
    FULL OUTER JOIN - Gets all the rows from tab1 and tab2
    LEFT OUTER JOIN - Gets all the rows from tab1 and only the row that matches with join condition from tab2.
    Here is a simple test.
    create table tab1(id integer)
    create table tab2(id integer)
    begin
      insert into tab1 values(1);
      insert into tab1 values(2);
      insert into tab1 values(3);
    end;
    begin
      insert into tab2 values(3);
      insert into tab2 values(4);
      insert into tab2 values(5);
    end;
    Select t1.id, t2.id
      from tab1 t1 full outer join tab2 t2
        on t1.id =t2.id
    Select t1.id, t2.id
      from tab1 t1, tab2 t2
    where t1.id = t2.id(+)
    /Run it and see the result.

  • Using FILTER after a FULL OUTER JOIN problem in OWB

    Hi,
    I’m using OWB 11.2.
    In an OWB mapping I need to detect every changes (Insert, Update, Delete) made to the data of a table. In order to find these changes I need to use “FULL OUTER JOIN” and a “FILTER” to join current table to previous table.
    My desired generated query should be like this:
    Select *
    From tab1 FULL OUTER JOIN tab2 on JOIN_CONDITION
    WHERE FILTER_CONDITION
    The problem is that when OWB generates the code, the query will be like this:
    Select *
    From tab1 FULL OUTER JOIN tab2 on JOIN_CONDITION AND FILTER_CONDITION
    As you know these 2 queries are not the same at all!
    I don’t know how to make OWB generate my desired SQL. Please help me…

    Works ok on 11.2.0.3
    Are you using "( + )" for join condition in joiner? Or, are you using "Join input role" parameter to define full outer join condition? Are you using oracle or ANSI syntax?

  • Full outer Join:ORA-01790

    Hi All,
    The issue may be silly, but we cant make it out:
        DB : Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProdWe are running the below query with no issues:
    select t1.text,t2.text text2,t1.line,decode(upper(t1.text),upper(t2.text),1,0) flg
    from
       (select text,row_number() over(order by line) line
        from user_source
       where name = 'COLL_MVIEW_REFRESH_PROC_LBK'
       and replace(trim(text),chr(10)) is not null
       ) t1,
       (select text ,row_number() over(order by line) line
        from user_source
        where name = 'COLL_MVIEW_REFRESH_PROC'
        and trim(replace(text,chr(10))) is not null) t2
    where t1.line = t2.lineBut when trying for an outer join it is giving error like
    ORA-01790: expression must have same datatype as corresponding expressionOuter Join Query:
    select t1.text,t2.text,t1.line,decode(upper(t1.text),upper(t2.text),1,0) flg
    from
       (select text,row_number() over(order by line) line
        from user_source
        where name = 'COLL_MVIEW_REFRESH_PROC_LBK'
        and replace(trim(text),chr(10)) is not null
        ) t1 full outer join
        (select text ,row_number() over(order by line) line
        from user_source
        where name = 'COLL_MVIEW_REFRESH_PROC'
        and trim(replace(text,chr(10))) is not null) t2
    on( t1.line = t2.line )Any idea what is wrong here?
    Thanks,
    Jeneesh

    Not sure what is wrong with your version. It might have to do with row_number not working on an empty row (outer joined).
    How about this alternative?
    The approach is a bit different, but it uses only one access to the user_source view.
    select s.lineNo, min(s.text1) text1, min(s.text2) text2, decode(upper(min(s.text1)), upper(min(s.text2)), 1, 0) flag
    from
    (select decode(u.name, 'COLL_MVIEW_REFRESH_PROC_LBK', u.text) text1
           ,decode(u.name, 'COLL_MVIEW_REFRESH_PROC'
    , u.text) text2
           ,u.name,
            row_number() over (partition by u.name order by u.line) lineNo
    from user_source u
    where u.name in ('COLL_MVIEW_REFRESH_PROC_LBK','COLL_MVIEW_REFRESH_PROC'
    /* and u.TYPE = 'PROCEDURE' */
    and replace(trim(u.text),chr(10)) is not null
    ) s
    group by s.lineNo
    order by s.lineNo;Edited by: Sven W. on Nov 18, 2008 5:24 PM

  • Full outer join ---  bug? Urgent

    Hi,
    I have a simple mapping using 2 source tables and doing an full outer join. While executing the mapping it is throwing me out with an error --
    Starting Execution LOAD_SAP
    Starting Task LOAD_SAP
    ORA-01790: expression must have same datatype as corresponding expression
    ORA-02063: preceding line from ODSD@LOC_TGT_LOC_ODSD
    ORA-06512: at "DWH_USER.LOAD_SAP", line 12
    ORA-06512: at "DWH_USER.LOAD_SAP", line 481
    ORA-06512: at "DWH_USER.LOAD_SAP", line 795
    ORA-06512: at "DWH_USER.LOAD_SAP", line 1973
    ORA-06512: at line 1
    Completing Task LOAD_SAP
    Completing Execution LOAD_SAP
    The SQL generated at line 12 is -
    CURSOR "JOIN_c" IS
    SELECT
    /*+ DRIVING_SITE("CONNECTION_LOC_TGT_LOC_ODSD") */
    "CONNECTION_LOC_TGT_LOC_ODSD"."END_USER_CUST_ID" "END_USER_CUST_ID",
    "SERVICE_LOC_TGT_LOC_ODSD"."SERVICE_NAME" "SERVICE_NAME",
    "CONNECTION_LOC_TGT_LOC_ODSD"."CE_CLLI" "CE_CLLI",
    "CONNECTION_LOC_TGT_LOC_ODSD"."PE_CLLI" "PE_CLLI"
    FROM "ODS"."CONNECTION"@"ODSD"@"LOC_TGT_LOC_ODSD" "CONNECTION_LOC_TGT_LOC_ODSD"
    FULL OUTER JOIN "ODS"."SERVICE"@"ODSD"@"LOC_TGT_LOC_ODSD" "SERVICE_LOC_TGT_LOC_ODSD" ON ("CONNECTION_LOC_TGT_LOC_ODSD"."END_USER_CUST_ID" = "SERVICE_LOC_TGT_LOC_ODSD"."END_USER_CUST_ID") ;
    If I replace the Full outer join with an equi join everything works fine. The SQL generated with an equi-join is ---
    SELECT
    /*+ DRIVING_SITE("CONNECTION_LOC_TGT_LOC_ODSD") */
    "CONNECTION_LOC_TGT_LOC_ODSD"."END_USER_CUST_ID" "END_USER_CUST_ID",
    "SERVICE_LOC_TGT_LOC_ODSD"."SERVICE_NAME" "SERVICE_NAME",
    "CONNECTION_LOC_TGT_LOC_ODSD"."CE_CLLI" "CE_CLLI",
    "CONNECTION_LOC_TGT_LOC_ODSD"."PE_CLLI" "PE_CLLI"
    FROM "ODS"."CONNECTION"@"ODSD"@"LOC_TGT_LOC_ODSD" "CONNECTION_LOC_TGT_LOC_ODSD",
    "ODS"."SERVICE"@"ODSD"@"LOC_TGT_LOC_ODSD" "SERVICE_LOC_TGT_LOC_ODSD" WHERE ( "CONNECTION_LOC_TGT_LOC_ODSD"."END_USER_CUST_ID" = "SERVICE_LOC_TGT_LOC_ODSD"."END_USER_CUST_ID" );
    We are using Oracle 9.2.0.4 AND OWB Clinet 9.2.0.2.8 and runtime repository 9.2.0.2.0.
    Any help on this appreciated?

    The discussion on this thread has moved to the later thread Problem with JOINs
    Nikolai

  • OBIEE not applying outer join syntax to filters

    (Note: I've already thoroughly searched the forums before posting this. Thanks)
    My problem is the following:
    I'm trying to build a report that is a count from my fact table, grouped by month from my date dimension for a given year, resulting in 12 data points. The problem is that not all months have actual data, but I still need those months to show on the report with a count of zero. Typical simple reporting requirement.
    I have already done the obvious and within my business layer made the join between my fact table and my date dimension an outer join on the fact side, just like you'd do if writing the query by hand. And when tested by hand this includes all dates for the year anyway, and when coupled with the appropriate null test on the count measure I'd get my 12 data points with zeros were appropriate.
    The problem is that there are additional filters I need to apply on the fact data (there are a couple text-based code values that didn't warrant full tables themselves so are just degenerate dimensions directly on the fact table.)
    When these filters are applied at the Answer level, I'm only getting back the months that actually have data, and lose the months where the count should be zero. A check of the session log for the query that was generated shows the problem. While OBI properly generates the outer-join syntax for the join itself between the two tables (my date dim and fact table) it does NOT apply the outer-syntax to the constant-based filter against the fact, effectively negating the outer join.
    Actual query from the log (I simply changed the table aliases from the ugly T##### stuff OBI generates to something more readable for posting here):
    select D.DT_MONTH_NAME as c1,
    D.DT_MONTH_NUM as c2,
    I.INC_TYPE as c3,
    I.INC_EMP_GROUP as c4,
    sum(case when I.INC_KEY is null then 0 else 1 end ) as c5
    from DATE_DIM D, INCIDENT_F I
    where ( D.DATE_KEY = I.DATE_KEY (+) ) and ( D.DT_YEAR = 2010 and I.INC_EMP_GROUP = 'CONTRACTOR' )
    group by D.DT_MONTH_NUM, D.DT_MONTH_NAME, I.INC_TYPE, I.INC_EMP_GROUP
    order by c2
    You can see that the outer syntax (+) is applied to the join, but not to the filter on I.INC_EMP_GROUP. If I take this query and drop it in something like SQL Developer, it only returns the months with data. If I throw the (+) after I.INC_EMP_GROUP like I'd do if writing this by hand, the desired zero-months results pop back in.
    I have already searched the forums and while lots of people seem to have asked this question, the only solutions involve things like trickery in the business layer using dummy fact tables followed by manipulations at the report level etc. Unfortunately I can't rely on these as the system is eventually to be turned over to users who can't be expected to apply various hacks to write reports.
    Anyone ever get to the bottom of getting OBI to apply outer join logic in filters as well, when the filtered table is meant to be outer-joined to?
    Any comments are appreciated.
    John

    I know that this thread is a bit old thought it might be helpful to some one...
    The Issue is, when using Degener@teDimen$ion ( this is !nner joned to FACT tables in BMM) and if any of the dimensions {other than theDegener@teDimen$ion (Let us say Dim X) } have an ()uter join to any of the fact tables, and you were doing your analysis using Degener@teDimen$ion,  Dim X, Measure value you will face the following issues.
    when filtering the analysis on the ()uter join dimension ( Dim X), the IN filter will not work. Reason is that the filter is getting applied to both the Dimension and FACT tables and the values that exist in Dimension Dim X but not in FACT table wont show up.
         The above issue can be fixed by changing the join between the fact and Degener@teDimen$ion from inner to outer. I think this is a bug.. because  it is supposed to filter the fact  table after the entire outer joined result is obtained but not filter the fact table for the Dim X values and do a outer join. I think the BI should be intelligent enough.

  • Full outer join

    CREATE TABLE FEE_BANDS_AUD1
        AUDIT_DATE TIMESTAMP (6) NOT NULL ENABLE,
        AUDIT_ACTION          VARCHAR2(30 BYTE) NOT NULL ENABLE,
        AUDIT_USER            VARCHAR2(8 BYTE) NOT NULL ENABLE,
        FEE_BANDS_ID          NUMBER NOT NULL ENABLE,
        FEE_RULE              VARCHAR2(10 BYTE) NOT NULL ENABLE,
        FEE_BAND_LOWER_LIMIT  NUMBER(19,0),
        FEE_BAND_HIGHER_LIMIT NUMBER(19,0),
        RATE_PERCENT          NUMBER(11,4),
        RATE_NUMBER           NUMBER(21,2),
        CAL_BASED_ON          CHAR(1 BYTE) NOT NULL ENABLE,
        REC_SEQ               NUMBER(5,0) NOT NULL ENABLE)
        FEE_BANDS_AUD
    INSERT INTO FEE_BANDS_AUD1 VALUES('18-10-10 06:31:56.625000000 AM','CREATE','sdn',1,'NSK',0,9999999999999999999,11,0,'B',0);
    INSERT INTO FEE_BANDS_AUD1 VALUES('18-10-10 06:53:08.659000000 AM','UPDATE','sdn',1,'NSK',0,100,11,0,'B',1);
    INSERT INTO FEE_BANDS_AUD1 VALUES('18-10-10 06:53:08.659000000 AM','UPDATE','sdn',2,'NSK',101,9999999999999999999,1,0,'B',1);
    INSERT INTO FEE_BANDS_AUD1 VALUES('18-10-10 06:54:51.354000000 AM','UPDATE','sdn',1,'NSK',0,100,11,0,'B',2);
    INSERT INTO FEE_BANDS_AUD1 VALUES('18-10-10 06:54:51.354000000 AM','UPDATE','sdn',2,'NSK',101,9999999999999999999,33,0,'B',2);
    INSERT INTO FEE_BANDS_AUD1 VALUES('18-10-10 07:15:16.354000000 AM','UPDATE','sdn',1,'NSK',0,100,11,0,'B',3);
    INSERT INTO FEE_BANDS_AUD1 VALUES('18-10-10 07:15:16.354000000 AM','UPDATE','sdn',2,'NSK',101,200,33,0,'B',3);
    INSERT INTO FEE_BANDS_AUD1 VALUES('18-10-10 07:15:16.354000000 AM','UPDATE','sdn',3,'NSK',201,9999999999999999999,1,0,'B',3);
    INSERT INTO FEE_BANDS_AUD1 VALUES('18-10-10 07:15:53.341000000 AM','UPDATE','sdn',1,'NSK',0,100,11,0,'B',4);
    INSERT INTO FEE_BANDS_AUD1 VALUES('18-10-10 07:15:53.341000000 AM','UPDATE','sdn',2,'NSK',101,200,33,0,'B',4);
    INSERT INTO FEE_BANDS_AUD1 VALUES('18-10-10 07:15:53.341000000 AM','UPDATE','sdn',3,'NSK',201,9999999999999999999,2,0,'B',4);     
    INSERT INTO FEE_BANDS_AUD1 VALUES('18-10-10 07:18:52.118000000 AM','UPDATE','sdn',1,'NSK',0,100,11,0,'B',5);
    INSERT INTO FEE_BANDS_AUD1 VALUES('18-10-10 07:18:52.118000000 AM','UPDATE','sdn',2,'NSK',101,9999999999999999999,2,0,'B',5);     I have a bandId, in which i will update a new band or delete a band. Each time when i insert,update or delete rec_seq is incremented to one to identify the old set of bands and new set of bands.
    My problem here is when i deleted a band (which is last two insert statments from the above) those are not coming in the old values . It should come in the old value set and new value should come as null.
    I am using full outer join because when i create a new record there wont be any old values in this case old values should come as null and also i delete any values there wont be any new value for that so new should come as null
    This is the query im trying
    select
    O.REC_SEQ,O.audit_action,O.fee_bands_id, O.FEE_RULE,
    O.FEE_BAND_LOWER_LIMIT, O.FEE_BAND_HIGHER_LIMIT,O.CAL_BASED_ON,
    N.REC_SEQ,n.audit_action,n.fee_bands_id, N.FEE_RULE,
    N.FEE_BAND_LOWER_LIMIT, N.FEE_BAND_HIGHER_LIMIT,N.CAL_BASED_ON
    from fee_bands_aud1 O FULL OUTER JOIN fee_bands_aud1 N
    on (N.fee_bands_id = O.fee_bands_id
    and N.FEE_RULE = O.FEE_RULE
    and O.REC_SEQ = N.REC_SEQ-1)
    where N.FEE_RULE = 'NSK'
    order by N.REC_SEQ, n.fee_bands_idwhat is the problem anybody please help i am very new to oracle.

    Yes, it's possible.
    Search for "full outer join" in the online manuals
    http://tahiti.oracle.com/pls/db92/db92.drilldown?levelnum=2&toplevel=a96540&method=FULL&chapters=0&book=&wildcards=1&preference=&expand_all=&verb=&word=full+outer+join+#a96540
    In the SQL Reference you can find an example

  • Full outer join Bug or my misunderstanding?

    CREATE GLOBAL TEMPORARY TABLE BP_ATTRIBUTE_CHARVAL_GTT
       (     "ATTRIBUTE_ID" NUMBER(10,0),
         "PARTNER_ID" NUMBER(10,0),
         "CHAR_VALUE" VARCHAR2(4000 BYTE),
         "LAST_UPDATE_DATE" DATE,
         "DISABLE_DATE" DATE
       ) ON COMMIT DEETE ROWS ;
    CREATE  TABLE BP_ATTRIBUTE_CHARVAL
       (     "ATTRIBUTE_ID" NUMBER(10,0),
         "PARTNER_ID" NUMBER(10,0),
         "CHAR_VALUE" VARCHAR2(4000 BYTE),
         "LAST_UPDATE_DATE" DATE,
         "DISABLE_DATE" DATE
    REM INSERTING into BP_ATTRIBUTE_CHARVAL
    Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (888854,710326,'1',to_date('29-NOV-06','DD-MON-RR'),to_date('01-JAN-06','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591330,710326,'01',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591321,710326,'N',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591331,710326,'00',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591329,710326,'01',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591332,710326,'01',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591324,710326,'2',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591333,710326,'01',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591323,710326,'X1',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591334,710326,'BS',to_date('09-FEB-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    REM INSERTING into BP_ATTRIBUTE_CHARVAL_GTT
    Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591330,707408,'01',to_date('29-MAR-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591321,707408,'N',to_date('23-JAN-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591331,707408,'00',to_date('23-JAN-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591329,707408,'01',to_date('23-JAN-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591332,707408,'00',to_date('29-MAR-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591324,707408,'2',to_date('29-MAR-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591333,707408,'01',to_date('23-JAN-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591323,707408,'X1',to_date('23-JAN-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (591334,707408,'BS',to_date('23-JAN-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (876570,707408,'01',to_date('29-MAR-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL_GTT (ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (876568,707408,'1234560003264801',to_date('29-MAR-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (876569,707408,'f3a1d996-720e-4e0a-989c-6d4f3e8e629a',to_date('29-MAR-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    Insert into BP_ATTRIBUTE_CHARVAL_GTT(ATTRIBUTE_ID,PARTNER_ID,CHAR_VALUE,LAST_UPDATE_DATE,DISABLE_DATE) values (874948,707408,'20060318000000',to_date('29-MAR-06','DD-MON-RR'),to_date('07-NOV-01','DD-MON-RR'));
    select 707408,    
           decode(g.attribute_id,NULL,c.attribute_id,g.attribute_id) attribute_id,
           case
           when c.last_update_date is null and g.last_update_date is not null
           then
              g.char_value
            when g.last_update_date is null and c.last_update_date is not null 
            then
              c.char_value
            when g.last_update_date >= c.last_update_date
            then
                 g.char_value
           else
                c.char_value
           end   char_value,        
           decode(g.last_update_date,c.last_update_date,g.last_update_date,c.last_update_date) last_update_date,
           decode(g.disable_date,c.disable_date,g.disable_date,c.disable_date) disable_date
    from bp_attribute_charval_gtt g
    full outer join
         bp_attribute_charval c
    on c.attribute_id = g.attribute_id    
    where c.partner_id=710326;Hi Guys
    When I run the above query I get a problem.
    I am expecting to see is a merge of all the attribute_id's and their values.
    The query does not appear to be merging the data as intended.
    My understanding of the full outer join is that its a combination of left and outer joins,
    so the above query is intended to return with the total number of unique attributes
    and their appropriate values
    a) I have a bug in the Sql
    b) This is an oracle bug
    c) My understanding is incorrect
    Please Help
    Message was edited by:
    Keith Jamieson (fixed insert statements for gtt )

    How do you expect a full outer join operation when you have given --
    where c.partner_id=710326;According to your supplied data - i don't think your query can perform that full outer join operation because of that filtration. Just remove that last condition and checked it. You will get your desired result - hopefully.
    "It's like you want to view the things by closing down your both eyes". Do you think it will pay?
    Regards.
    Satyaki De.

  • Using full outer join of subqueries named using with clause

    Hi,
    I am trying to create a view which is having 2 subqueries vol1 & vol2 with WITH clause. I am joining those 2 subqueries in the main query with FULL OUTER JOIN.
    When i compile that view in a tool like pl/sql developer, It has been compiled successfully.
    But when i call the view creation script from SQL command prompt, It is throwing error as
    from vol1 FULL JOIN vol2 o ON (vol1.ct_reference = vol2.ct_reference and vol1.table_name = vol2.table_name
    ERROR at line 29:
    ORA-00942: table or view does not exist
    Kindly advise whats going wrong.

    that's line 29. Maybe you get a better idea if you strip your operation of all the unneccessary elements until it works.
    There are some known bugs with subquery factoring (aka with clause) and also with ANSI join syntax, but it is hard to tell what happens here based on your description. But one thing is strange - if it is not a result of formatting (not formatting): I would expect the asterisk beneath the unknown table and not beneath the key word FULL.
    P.S.: my editor makes me think it's rather a proportional font thing. Have I already said that I don't like proportional font for SQL code examples?

  • Help Required in full outer Join

    I feel the below query can be changed to full outer join. But, I've not been able to do so.
    I require your help in changing it to full outer join. My current query is
    SELECT CLAIMNO,'1' INDX FROM D_CLAIM@CMS2PROD
    WHERE clntsys=76500 and facility=76501 and filecreatedt='18-feb-2011' and fileupdatedt is null
    MINUS
    SELECT CLAIMNO,'1' FROM D_CLAIM
    WHERE clntsys=76500 and facility=76501 and filecreatedt='18-feb-2011' and fileupdatedt is null
    UNION
    SELECT CLAIMNO,'2' FROM D_CLAIM
    WHERE clntsys=76500 and facility=76501 and filecreatedt='18-feb-2011' and fileupdatedt is null
    MINUS
    SELECT CLAIMNO,'2' FROM D_CLAIM@cms2prod
    WHERE clntsys=76500 and facility=76501 and filecreatedt='18-feb-2011' and fileupdatedt is null

    donisback wrote:
    I feel the below query can be changed to full outer join. But, I've not been able to do so.
    I require your help in changing it to full outer join. My current query is
    SELECT CLAIMNO,'1' INDX FROM D_CLAIM@CMS2PROD
    WHERE clntsys=76500 and facility=76501 and filecreatedt='18-feb-2011' and fileupdatedt is null
    MINUS
    SELECT CLAIMNO,'1' FROM D_CLAIM
    WHERE clntsys=76500 and facility=76501 and filecreatedt='18-feb-2011' and fileupdatedt is null
    UNION
    SELECT CLAIMNO,'2' FROM D_CLAIM
    WHERE clntsys=76500 and facility=76501 and filecreatedt='18-feb-2011' and fileupdatedt is null
    MINUS
    SELECT CLAIMNO,'2' FROM D_CLAIM@cms2prod
    WHERE clntsys=76500 and facility=76501 and filecreatedt='18-feb-2011' and fileupdatedt is null
    I do not think that query is doing what you think that it is doing - on first inspection, it was not doing what I thought either due to the order in which the UNION and MINUS operators are performed. If the FILECREATEDT column is defined as a DATE, your query is relying on an implicit date conversion - in such a case, you should replace:
    filecreatedt='18-feb-2011'With:
    filecreatedt=TO_DATE('18-feb-2011','DD-MON-YYYY')Now, building a simple model to explain what is happening, we create two tables with 10 rows each. The first table has C1 values that increase by 2, while the second has C1 values that increase by 3:
    CREATE TABLE T1 AS
    SELECT
      ROWNUM*2 C1,
      TRUNC(SYSDATE)+ROWNUM*2 C2
    FROM
      DUAL
    CONNECT BY
      LEVEL<=10;
    CREATE TABLE T2 AS
    SELECT
      ROWNUM*3 C1,
      TRUNC(SYSDATE)+ROWNUM*3 C2
    FROM
      DUAL
    CONNECT BY
      LEVEL<=10;It appears that the intended result of your query is to obtain a distinct list of those rows that are in each table that are not in both tables - the UNION ALL minus the intersection of the rows in two tables. However, that is not what you are achieving with that query. To demonstrate, the two halves of your query:
    SELECT
      C1,
      C2
    FROM
      T1
    MINUS
    SELECT
      C1,
      C2
    FROM
      T2;
    C1 C2
    2 28-FEB-11
    4 02-MAR-11
    8 06-MAR-11
    10 08-MAR-11
    14 12-MAR-11
    16 14-MAR-11
    20 18-MAR-11
    SELECT
      C1,
      C2
    FROM
      T2
    MINUS
    SELECT
      C1,
      C2
    FROM
      T1;
    C1 C2
    3 01-MAR-11
    9 07-MAR-11
    15 13-MAR-11
    21 19-MAR-11
    24 22-MAR-11
    27 25-MAR-11
    30 28-MAR-11As can be seen by the above, each half returned 7 rows - there are 7 rows in each table that is not in the other table. Common sense would state that if we UNION these two results (assuming no duplicate values in each table), we would see 14 rows:
    SELECT
      C1,
      C2
    FROM
      T1
    MINUS
    SELECT
      C1,
      C2
    FROM
      T2
    UNION
    SELECT
      C1,
      C2
    FROM
      T2
    MINUS
    SELECT
      C1,
      C2
    FROM
      T1;
    C1 C2
    3 01-MAR-11
    9 07-MAR-11
    15 13-MAR-11
    21 19-MAR-11
    24 22-MAR-11
    27 25-MAR-11
    30 28-MAR-11Only 7 rows? Let's try again with the help of inline views to control the order in which the MINUS and UNION operators are processed:
    SELECT
    FROM
      (SELECT
        C1,
        C2
      FROM
        T1
      MINUS
      SELECT
        C1,
        C2
      FROM
        T2)
    UNION
    SELECT
    FROM
      (SELECT
        C1,
        C2
      FROM
        T2
      MINUS
      SELECT
        C1,
        C2
      FROM
        T1);
    C1 C2
    2 28-FEB-11
    3 01-MAR-11
    4 02-MAR-11
    8 06-MAR-11
    9 07-MAR-11
    10 08-MAR-11
    14 12-MAR-11
    15 13-MAR-11
    16 14-MAR-11
    20 18-MAR-11
    21 19-MAR-11
    24 22-MAR-11
    27 25-MAR-11
    30 28-MAR-11Note that the above returned 14 rows. We can do the same using just two outer joins:
    SELECT
      T1.C1,
      T1.C2
    FROM
      T1,
      T2
    WHERE
      T1.C1=T2.C1(+)
      AND T2.C1 IS NULL
    UNION
    SELECT
      T2.C1,
      T2.C2
    FROM
      T1,
      T2
    WHERE
      T2.C1=T1.C1(+)
      AND T1.C1 IS NULL;
    C1 C2
    2 28-FEB-11
    3 01-MAR-11
    4 02-MAR-11
    8 06-MAR-11
    9 07-MAR-11
    10 08-MAR-11
    14 12-MAR-11
    15 13-MAR-11
    16 14-MAR-11
    20 18-MAR-11
    21 19-MAR-11
    24 22-MAR-11
    27 25-MAR-11
    30 28-MAR-11Or we can do it with a full outer join and a MINUS operator:
    SELECT
      NVL(T1.C1,T2.C1) C1,
      NVL2(T1.C1,T1.C2,T2.C2) C2
    FROM
      T1 FULL OUTER JOIN T2
        ON T1.C1=T2.C1
    MINUS
    SELECT
      T1.C1,
      T1.C2
    FROM
      T1,
      T2
    WHERE
      T1.C1=T2.C1;
    C1 C2
    2 28-FEB-11
    3 01-MAR-11
    4 02-MAR-11
    8 06-MAR-11
    9 07-MAR-11
    10 08-MAR-11
    14 12-MAR-11
    15 13-MAR-11
    16 14-MAR-11
    20 18-MAR-11
    21 19-MAR-11
    24 22-MAR-11
    27 25-MAR-11
    30 28-MAR-11Or just with a full outer join with a WHERE clause:
    SELECT
      NVL(T1.C1,T2.C1) C1,
      NVL2(T1.C1,T1.C2,T2.C2) C2
    FROM
      T1 FULL OUTER JOIN T2
        ON T1.C1=T2.C1
    WHERE
      (T1.C1 IS NULL
        OR T2.C1 IS NULL);
    C1 C2
    3 01-MAR-11
    9 07-MAR-11
    15 13-MAR-11
    21 19-MAR-11
    24 22-MAR-11
    27 25-MAR-11
    30 28-MAR-11
    8 06-MAR-11
    20 18-MAR-11
    2 28-FEB-11
    10 08-MAR-11
    4 02-MAR-11
    14 12-MAR-11
    16 14-MAR-11With the above knowledge, you should be able to fix your SQL statement to produce the expected results.
    Charles Hooper
    Co-author of "Expert Oracle Practices: Oracle Database Administration from the Oak Table"
    http://hoopercharles.wordpress.com/
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.

  • Full outer join query giving error

    Hi I have written the below query to get the fields below as an out put but am getting the error missing keyword..am not understanding where did i missed..i have done step by step query analysis..but could not find the error.
    Please help me in resolving the issue.
    Expected output Columns :*
    COUNTRY , TRN_TYPE ,SKU ,BIX_Customer ,PERIOD ,CURRENTSTOCK ,STOCK_VALUE ,SALES ,SALES_VALUE ,TARGET
    Query :_
    select (case when a.country is null then b.country when b.country is null then c.country else a.country end) AS COUNTRY,
    (case when a.Sale_Type is null then b.Stk_type when b.stk_type is null then c.Stk_type else a.Sale_Type end) AS TRN_TYPE,
    (case when a.sku is null then b.sku when b.sku is null then c.sku else a.sku end) AS SKU,
    (case when a.bix_customer is null then b.bix_customer_code when b.bix_customer_code is null then c.bix_customer_code else a.bix_customer end)AS BIX_Customer ,
    (case when a.period is null then TO_number(b.period) when b.period is null then TO_NUMBER(c.period) else a.period end) AS PERIOD,
    nvl(b.CURRENTSTOCK,0) AS CURRENTSTOCK,
    nvl(b.stock_value,0) AS STOCK_VALUE,
    nvl(a.sales,0) AS SALES,
    nvl(a.SALES_VALUE,0) AS SALES_VALUE,
    nvl(c.TARGET_QTY,0) AS TARGET
    from
    (select UPPER(c.cust_country_name) AS COUNTRY,
    DECODE(ds.account_key,7156,'SAMPLE',7157,'BONUS',7485,'SALE') AS Sale_Type,
    substr(i.item_code,7) AS SKU,
    c.bix_customer_code AS BIX_Customer,
    ds.descr as descr ,
    ds.period as period,
    sum(ds.quantity) AS SALES,
    sum(case when ds.local_value is null then ds.euro_value else ds.local_value END) AS SALES_VALUE
    FROM distributor_sales ds, customer c, item i
    where ds.customer_key=c.customer_key
    and ds.item_key= i.item_key
    group by ds.period,
    ds.account_key,
    c.cust_country_name,
    substr(i.item_code,7),
    c.bix_customer_code,
    ds.descr) a
    full outer join
    (SELECT UPPER(b.cust_country_name) AS COUNTRY,
    DECODE(s.stock_type,'SALE','SALE','SALES','SALE','BONUS','BONUS','SAMPLE','SAMPLE') AS Stk_type,
    substr(c.item_code,7) AS SKU,
    s.descr as descr,
    s.period as period,
    b.bix_customer_code,
    sum(s.CLOSING_STOCK) CURRENTSTOCK,
    sum(s.closing_stock*s.cif_price) STOCK_VALUE
    FROM STOCK s, customer b, item c
    WHERE s.customer_key=b.customer_key
    and s.item_key= c.item_key
    group by
    s.descr,
    s.stock_type,
    s.period, b.bix_customer_code,b.cust_country_name,substr(c.item_code,7) ) b
    full outer join
    (SELECT UPPER(cu.cust_country_name) AS COUNTRY,
    DECODE(t.description,'SALES TARGET','SALE') AS Stk_type,
    substr(it.item_code,7) AS SKU,
    t.channel as channel,
    t.period as period,
    cu.bix_customer_code as bix_customer_code,
    sum(t.quantity) TARGET_QTY
    FROM sales_target t, customer cu, item it
    WHERE t.customer_key=cu.customer_key
    and t.item_key= it.item_key
    group by
    t.channel,
    t.description,
    t.period, cu.bix_customer_code,cu.cust_country_name,substr(it.item_code,7) ) c
    on a.SKU=b.SKU
    and a.sku=c.SKU
    and b.sku=c.SKU
    and a.BIX_Customer=b.bix_customer_code
    and a.BIX_Customer=c.bix_customer_code
    and b.bix_customer_code=c.bix_customer_code
    and a.Sale_Type=b.Stk_type
    and a.Sale_Type=c.Stk_type
    and b.Stk_type=c.Stk_type
    and a.descr=b.descr
    and b.descr=c.channel
    and a.descr=c.channel
    and a.country=b.country
    and a.country=c.COUNTRY
    and b.country=c.COUNTRY
    and a.period=b.period
    and a.period=c.period
    and b.period=c.period;

    <tt>Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production</tt>
    You must be aware that you must cascade full outer joins
    with
    t1 as
    (select 1 key,1.1 data from dual union all
    select 3,1.3 from dual union all
    select 6,1.6 from dual union all
    select 7,1.7 from dual
    t2 as
    (select 2 key,2.2 data from dual union all
    select 3,2.3 from dual union all
    select 4,2.4 from dual union all
    select 6,2.6 from dual
    t3 as
    (select 4 key,3.4 data from dual union all
    select 5,3.5 from dual union all
    select 6,3.6 from dual union all
    select 7,3.7 from dual
    select nvl(x.key,t3.key) key,
           x.data_1,
           x.data_2,
           t3.data data_3
      from (select nvl(t1.key,t2.key) key,
                   t1.data data_1,
                   t2.data data_2
              from t1
                   full outer join
                   t2
                on t1.key = t2.key
           ) x
           full outer join
           t3
        on t3.key = x.key
    order by keyunless you can live with duplicate key rows you cannot avoid whenever all table pairs contain common keys (try the below using data from above)
    select coalesce(t1.key,t2.key,t3.key) key,
           t1.data data_1,
           t2.data data_2,
           t3.data data_3
      from t1
           full outer join
           t2
        on t1.key = t2.key
           full outer join
           t3
        on t3.key = t1.key
       and t3.key = t2.key
    order by key
    select coalesce(t1.key,t2.key,t3.key) key,
           t1.data data_1,
           t2.data data_2,
           t3.data data_3
      from t2
           full outer join
           t3
        on t2.key = t3.key
           full outer join
           t1
        on t1.key = t2.key
       and t1.key = t3.key
    order by key
    select coalesce(t1.key,t2.key,t3.key) key,
           t1.data data_1,
           t2.data data_2,
           t3.data data_3
      from t1
           full outer join
           t3
        on t1.key = t3.key
           full outer join
           t2
        on t2.key = t1.key
       and t2.key = t3.key
    order by keyRegards
    Etbin
    Edited by: Etbin on 10.4.2013 9:53
    If you're after
    select *
      from (select *
              from (select *
                      from t1
                   ) a
                   full outer join
                   (select *
                      from t2
                   ) b
                on t1.key = t2.key
           ) x
           full outer join
           t3
        on t3.key = x.key
    order by keyyou're presently at
    select *
      from (
                   (select *
                      from t1
                   ) a
                   full outer join
                   (select *
                      from t2
                   ) b
                on t1.key = t2.key
           ) x
           full outer join
           t3
        on t3.key = x.key
    order by keyORA-00933: SQL command not properly ended

  • Granting SELECT to user on VIEW with FULL OUTER JOIN fails?

    I have a quandary.
    Using Oracle 9i, I have created a simple view. When I perform a count on it, rows are returned.
    However, when I grant SELECT access to another user, they can't see the VIEW. The VIEW has a FULL OUTER JOIN operation in it.
    When I do the same thing using a regular join, it works.
    Any ideas why, please?
    SQL> conn ifsinfo/******@DB
    Connected.
    SQL> ed
    Wrote file afiedt.buf
      1  create view mctest3 as
      2  select
      3   vc.idcus ,
      4   ci.customer_id
      5  from
      6   ifsapp.vmo_company vc
      7  full outer join
      8   ifsapp.customer_info ci
      9  on
    10*  vc.custno = ci.customer_id
    SQL> /
    View created.
    SQL> select count(*) from mctest3;
      COUNT(*)
         73994
    SQL> GRANT SELECT ON MCTEST3 TO IFSAPP WITH GRANT OPTION;
    Grant succeeded.
    SQL> CONN IFSAPP/******@DB
    Connected.
    SQL> select count(*) from IFSINFO.MCTEST3;
    select count(*) from IFSINFO.MCTEST3
    ERROR at line 1:
    ORA-00942: table or view does not existbut with regular join:
    SQL> conn ifsinfo/******@DB
    Connected.
    SQL> create view mctest4 as
      2    select
      3     vc.idcus ,
      4     ci.customer_id
      5    from
      6     ifsapp.vmo_company vc, ifsapp.customer_info ci
      7    where vc.custno = ci.customer_id;
    View created.
    SQL> select count(*) from mctest4;
      COUNT(*)
         44269
    SQL> GRANT SELECT ON MCTEST4 TO IFSAPP WITH GRANT OPTION;
    Grant succeeded.
    SQL> conn ifsapp/******@DB
    Connected.
    SQL> select count(*) from IFSINFO.MCTEST4;
      COUNT(*)
         44269

    Hi,
    >>SQL> conn ifsinfo/******@DB
    Connected.
    SQL> ed
    Wrote file afiedt.buf
    1 create view mctest3 as
    2 select
    3 vc.idcus ,
    4 ci.customer_id
    5 from
    6 ifsapp.vmo_company vc
    7 full outer join
    8 ifsapp.customer_info ci
    9 on
    10* vc.custno = ci.customer_id
    SQL> /
    According to Note:244315.1, it is not possible to make a FULL OUTER JOIN on views owned by another user at the 9i version of Oracle. As above, do not use FULL OUTER JOIN on views owned by another user. Try to use outer join operator (+), and/or UNIONS instead.
    Cheers

Maybe you are looking for

  • ANN: XML Class Generator for Java Available

    The Oracle XMCL Class Generator for Java is now available as an initial beta release on the Oracle Technology Network at http://technet.oracle.com. Select 'xml' from the Technology menu. The XML Class Generator will generate a set of Java source file

  • One iTunes Store account, two computers, really need help!

    Ok, I have just one iTunes store account however i had 2 different computers i used to download the music. my home computer was originally the one i used but then when i moved, i lost internet so my boss let me use my work computer. however after abo

  • OS 10.6.1 Printing to an HP LaserJet 5000n

    Since I upgraded to Snow Leopard a few weeks ago, I've been unable to print to my LaserJet 5000n printer. Drivers seem to be unavailable, although the initial compatibility charts indicated that it shouldn't be a problem. Nothing shows up in the prin

  • CS6 Bridge and Mini Bridge problems

    Installed CS6 and clicked on Brose in Bridge.  I get the rror messare could not complete the Brose in Bridge commmand because Photoshop was unable to find the Java Script plugin.  Also when clicking on Brose in Mini Bridge I get the message cannot co

  • Oracle Instant Client for Intel MacOS X

    Hi all, this is my first post here (so I don't know if it's the proper place, but to try it is free. Sorry for any inconvenience). Anybody, can confirm/explain why, one year after launch, there isn't one available download of Oracle Instant Client fo