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?

Similar Messages

  • Analytical using FULL outer join

    Hi,
    Please execute the below script and check the output for the given select query the output gives rnum alias value as null which should not be the case. I am just wondering what is wrong in this case
    CREATE TABLE A
    ID INTEGER,
    RD INTEGER,
    SD DATE
    CREATE TABLE B
    ID INTEGER,
    RD INTEGER,
    SD DATE
    INSERT INTO A VALUES (
    30001, 200, TO_Date( '01/01/2007 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
    INSERT INTO A VALUES (
    30001, 200, TO_Date( '01/02/2007 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
    INSERT INTO A VALUES (
    30001, 250, TO_Date( '01/01/2007 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
    INSERT INTO B VALUES (
    30001, 300, TO_Date( '01/01/2007 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
    INSERT INTO B VALUES (
    30001, 300, TO_Date( '01/02/2007 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
    INSERT INTO B VALUES (
    30001, 250, TO_Date( '01/02/2007 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
    INSERT INTO B VALUES (
    30001, 200, TO_Date( '01/01/2007 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
    COMMIT;
    SELECT NVL(aa.id, ba.id) , aa.rd,aa.sd, ba.rd,ba.sd,aa.rnum,ba.rnum
    FROM
    (SELECT a.id, a.rd, a.sd , row_number() OVER(PARTITION BY a.id, a.rd ORDER BY a.rd) AS rnum
    FROM A) a FULL OUTER JOIN
    (SELECT b.id, b.rd, b.sd , row_number() OVER(PARTITION BY b.id, b.rd ORDER BY b.rd) AS rnum
    FROM B) b
    ON
    a.rd = b.rd
    AND
    a.id = b.id
    AND
    a.rnum = b.rnum
    Message was edited by:
    vsugur
    Message was edited by:
    vsugur

    Which version are you using? Maybe is a bug.
    Try this:with aa as ( SELECT a.id, a.rd, a.sd ,
                      row_number() OVER ( PARTITION BY a.id, a.rd ORDER BY a.rd ) AS rnum
                      FROM a ),
    bb as ( SELECT b.id, b.rd, b.sd ,
               row_number() OVER(PARTITION BY b.id, b.rd ORDER BY b.rd) AS rnum
               FROM b)
    SELECT NVL(aa.id, bb.id) id, aa.rd ard, aa.sd asd, bb.rd brd, bb.sd bsd,
                 aa.rnum arum, bb.rnum brum
    FROM aa FULL OUTER JOIN bb
    ON aa.rd = bb.rd AND
          aa.id = bb.id AND
          aa.rnum = bb.rnum;

  • How to merge 3 different query results using full outer join?

     Hi all This is my my query for 2 results
    with t1 as (
    select trans.crAcc_id,trans.cr_amt,row_number() over (order by trans.head_id) rn from Acttrans trans,
     Acttranhead head where trans.head_id in(select link_id from acttrans where head_id=12) and trans.crAcc_id!=0
     and head.head_id=trans.head_id
    t2 as (
    select trans.drAcc_id,trans.dr_amt,head.[Vouc_No],head.[Vouc_Date] ,head.[Check_No],head.[Check_Date],head.[stat],row_number() over (order by trans.head_id) rn from Acttrans trans,
     Acttranhead head where trans.head_id=12 and trans.drAcc_id!=0
     and head.head_id=trans.head_id
     select t1.crAcc_id, t1.cr_amt,t2.[Vouc_No],t2.[Vouc_Date] ,t2.[Check_No],t2.[Check_Date],t2.[stat],t2.drAcc_id,t2.dr_amt from t1
      full outer join t2 on t1.rn = t2.rn
    Query 3: SELECT [CrAcc_Id]  FROM [KSSDATA].[dbo].[ActTrans] where head_id=12 and crAcc_id!=0
    and i want to add Query3 result to the ABOVE RESULT but i am unable add third result using full outer join
    Thanks
    Balu D

    >>>but i am unable add third result using full outer join
    Do you get the error or wrong result?
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

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

  • Unable to collapse rows after full outer joining several tables

    All -
    I often do a "full outer join" on numerous tables when I want to report all of the
    contents of all of the tables in one relatively easy to inspect set of output. However,
    now that my "leading" table is missing certain values, my output is definitely not
    what I want.
    Here's a test case:
    drop table test11;
    create table test11 (x number);
    insert into test11 values (1);
    insert into test11 values (3);
    drop table test12;
    create table test12 (x number);
    insert into test12 values (2);
    insert into test12 values (3);
    drop table test13;
    create table test13 (x number);
    insert into test13 values (1);
    insert into test13 values (2);
    drop table test14;
    create table test14 (x number);
    insert into test14 values (2);
    commit;
    select test11.x t11,
    test12.x t12,
    test13.x t13,
    test14.x t14
    from (((test11 full outer join test12 on test11.x = test12.x)
    full outer join test13 on test11.x = test13.x)
    full outer join test14 on test11.x = test14.x);
    And here is the output:
    T11 T12 T13 T14
    1 1
    3 3
    2
    2
    2
    5 rows selected.
    Forgive me if this doesn't appear with a fixed-width font. I
    don't know how to format these postings.
    See rows 3, 4, and 5? My desire is to jam those
    together so that my output is this instead:
    T11 T12 T13 T14
    1 1
    3 3
    2 2 2
    3 rows selected.
    Do you have any idea how to do this? Of course, I'll need to
    apply the solution to the general case so that all
    test cases similar to this are fixed!
    Thanks very much for your time!
    Tom G.

    For anyone who's interested -
    Here is the solution I was able to put together on my own:
    select max(t11) t11, max(t12) t12, max(t13) t13, max(t14) t14 from
    select coalesce(test11.x, test12.x, test13.x, test14.x) ct,
           test11.x    t11,
           test12.x    t12,
           test13.x    t13,
           test14.x    t14
      from (((test11 full outer join test12 on test11.x = test12.x)
                    full outer join test13 on test11.x = test13.x)
                    full outer join test14 on test11.x = test14.x))
    group by ct;And the output:
           T11        T12        T13        T14
                        2          2          2
             1                     1
             3          3
    3 rows selected.Bye,
    Tom G.

  • Fact vertical capabilities - Full outer Join - How to?

    Hi,
    I have the same problem described in another post: Forcing full outer join between two facts according to common dimensions
    I will use the same example:
    Let's assume 2 fact tables F1 and F2 and 2 dimension D1 and D2.
    Fi is joined to Dj thanks to IDs.
    F1 and F2 have got aggregates sum(mes1), respectively sum(mes2).
    The group by is performed on dim1 for D1 and dim2 for D2.
    The following 2 queries work fine...but separately:
    select dim1, dim2, sum(mes1) from F1, D1, D2 where ... group by dim1, dim2; //7 lines
    select dim1, dim2, sum(mes2) from F2, D1, D2 where ... group by dim1, dim2; //8 lines
    When I try to select dim1, dim2, sum(mes1) and sum(mes2), the following sql is created by the BI server:
    WITH SAWITH0 AS (
    select dim1, dim2, sum(mes1) c3 from F1, D1, D2 where ... group by dim1, dim2
    ), SAWITH1 AS (
    select dim1, dim2, sum(mes2) c3 from F2, D1, D2 where ... group by dim1, dim2
    select ... dim1,
    ... dim2,
    ... SAWITH0.c3,
    ... SAWITH1.c3
    FROM SAWITH0 LEFT OUTER JOIN SAWITH1
    on SAWITH0.dim1=SAWITH1.dim1 and SAWITH0.dim2=SAWITH1.dim2
    I get only 7 lines. It means I miss one line from the second query on F2.
    The solution is to perform a full outer join between both queries..
    The reply was a link to fact vertical capabilities of OBIEE
    (http://gerardnico.com/wiki/dat/obiee/logical_sql/obiee_full_outer_join)
    (http://gerardnico.com/wiki/dat/obiee/bi_server/design/obiee_densification_design_preservation_dimension)
    In this post the solution is to add a dummy fact table to force a crossjoin.
    This solution don't work in my case because I don't need to return all the members of the dimension, I just need to return the dimension member that are joined to both facts..
    if in the example, the dimension have 20 member with the fact vertical capabilities solution my reports will show 20 rows... and I only want to see 8 rows...
    Any Idea?
    Thanks...

    I found what was the real problem:
    I have two diferent physical and logical Facts with 4 common dimensions and 1 dimesion that only affect to the second fact.
    In my report I'm filtering for this last dimension so the OBI use this query (the more restrictive) and made a left join with the second result...
    The problem is what I need is filter only by the column, but I cant do it because I'm using a column selector and I can't do a FILTER USING statement using a dashboard prompt...
    Any Idea?
    Thanks

  • 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

  • How can I join/Full outer join two different columns instead of union all?

    Hi,
    I have a scenario as the following:
    I am performing set operations using obiee 11g where I want to take values from two different criteria. Howwver, I dont want union to take place, instead i want join to take place to see all the columns in the output.
    For that, I tried changing the sql in advanced tab and tried to put full outer join instead of union all but its not allowing me to change.
    How can I achieve it? please help.
    Thanks.

    Hi,
    My problem is that I am unable to modify the sql in advanced tab. Probably due to some security reason,it's restricting me to change.
    Can you suggest me a way to change it?
    Thanks..

  • 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

  • Join-types right & full outer join with Datasets

    Hello
    I use Crystal Reports XI Release 2 with ADO.NET Datasets as datasource. In the "Database-Expert" I try to set the "Link-Options". Unfortunately are the join-types "right outer join" and "full outer join" disabled.
    - Is this because of the datasource Dataset?
    - Is there e possibility to build the Dataset so I can use this two joins?
    - If not, is it possible in a newer version?
    Thanks, T.Fitzi

    Hi
    I think this is the problem. I don't connect directly to a database. My application (C#) provieds Crystal Report with a dataset. So all my data is in this dataset.
    Are this joins in the new version stil disabled?
    Regards, Thomas

  • 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

  • [8i] Need help with full outer join combined with a cross-join....

    I can't figure out how to combine a full outer join with another type of join ... is this possible?
    Here's some create table and insert statements for some basic sample data:
    CREATE TABLE     my_tab1
    (     record_id     NUMBER     NOT NULL     
    ,     workstation     VARCHAR2(4)
    ,     my_value     NUMBER
         CONSTRAINT my_tab1_pk PRIMARY KEY (record_id)
    INSERT INTO     my_tab1
    VALUES(1,'ABCD',10);
    INSERT INTO     my_tab1
    VALUES(2,'ABCD',15);
    INSERT INTO     my_tab1
    VALUES(3,'ABCD',5);
    INSERT INTO     my_tab1
    VALUES(4,'A123',5);
    INSERT INTO     my_tab1
    VALUES(5,'A123',10);
    INSERT INTO     my_tab1
    VALUES(6,'A123',20);
    INSERT INTO     my_tab1
    VALUES(7,'????',5);
    CREATE TABLE     my_tab2
    (     workstation     VARCHAR2(4)
    ,     wkstn_name     VARCHAR2(20)
         CONSTRAINT my_tab2_pk PRIMARY KEY (workstation)
    INSERT INTO     my_tab2
    VALUES('ABCD','WKSTN 1');
    INSERT INTO     my_tab2
    VALUES('A123','WKSTN 2');
    INSERT INTO     my_tab2
    VALUES('B456','WKSTN 3');
    CREATE TABLE     my_tab3
    (     my_nbr1     NUMBER
    ,     my_nbr2     NUMBER
    INSERT INTO     my_tab3
    VALUES(1,2);
    INSERT INTO     my_tab3
    VALUES(2,3);
    INSERT INTO     my_tab3
    VALUES(3,4);And, the results I want to get:
    workstation     sum(my_value)     wkstn_name     my_nbr1     my_nbr2
    ABCD          30          WKSTN 1          1     2
    ABCD          30          WKSTN 1          2     3
    ABCD          30          WKSTN 1          3     4
    A123          35          WKSTN 2          1     2
    A123          35          WKSTN 2          2     3
    A123          35          WKSTN 2          3     4
    B456          0          WKSTN 3          1     2
    B456          0          WKSTN 3          2     3
    B456          0          WKSTN 3          3     4
    ????          5          NULL          1     2
    ????          5          NULL          2     3
    ????          5          NULL          3     4I've tried a number of different things, googled my problem, and no luck yet...
    SELECT     t1.workstation
    ,     SUM(t1.my_value)
    ,     t2.wkstn_name
    ,     t3.my_nbr1
    ,     t3.my_nbr2
    FROM     my_tab1 t1
    ,     my_tab2 t2
    ,     my_tab3 t3
    ...So, what I want is a full outer join of t1 and t2 on workstation, and a cross-join of that with t3. I'm wondering if I can't find any examples of this online because it's not possible....
    Note: I'm stuck dealing with Oracle 8i
    Thanks!!

    Hi,
    The query I posted yesterday is a little more complicated than it needs to be.
    Since my_tab2.workstation is unique, there's no reason to do a separate sub-query like mt1; we can join my_tab1 to my_tab2 and get the SUM all in one sub-query.
    SELECT       foj.workstation
    ,       foj.sum_my_value
    ,       foj.wkstn_name
    ,       mt3.my_nbr1
    ,       mt3.my_nbr2
    FROM       (     -- Begin in-line view foj for full outer join
              SELECT        mt1.workstation
              ,        SUM (mt1.my_value)     AS sum_my_value
              ,        mt2.wkstn_name
              FROM        my_tab1   mt1
              ,        my_tab2   mt2
              WHERE        mt1.workstation     = mt2.workstation (+)
              GROUP BY   mt1.workstation
              ,        mt2.wkstn_name
                    UNION ALL
              SELECT      workstation
              ,      0      AS sum_my_value
              ,      wkstn_name
              FROM      my_tab2
              WHERE      workstation     NOT IN (     -- Begin NOT IN sub-query
                                               SELECT      workstation
                                       FROM      my_tab1
                                       WHERE      workstation     IS NOT NULL
                                     )     -- End NOT IN sub-query
           ) foj     -- End in-line view foj for full outer join
    ,       my_tab3  mt3
    ORDER BY  foj.wkstn_name
    ,       foj.workstation
    ,       mt3.my_nbr1
    ,       mt3.my_nbr2
    ;Thanks for posting the CREATE TABLE and INSERT statements, as well as the very clear desired results!
    user11033437 wrote:
    ... So, what I want is a full outer join of t1 and t2 on workstation, and a cross-join of that with t3. That it, exactly!
    The tricky part is how and when to get SUM (my_value). You might approach this by figuring out exactly what my_tab3 has to be cross-joined to; that is, exactly what should the result set of the full outer join between my_tab1 and my_tab2 look like. To do that, take your desired results, remove the columns that do not come from the full outer join, and remove the duplicate rows. You'll get:
    workstation     sum(my_value)     wkstn_name
    ABCD          30          WKSTN 1          
    A123          35          WKSTN 2          
    B456          0          WKSTN 3          
    ????          5          NULL          So the core of the problem is how to get these results from my_tab1 and my_tab2, which is done in sub-query foj above.
    I tried to use self-documenting names in my code. I hope you can understand it.
    I could spend hours explaining different parts of this query in more detail, but I'm sure I'd waste some of that time explaining things you already understand. If you want an explanation of somthing(s) specific, let me know.

  • SQL Query Assistance Required for Full Outer Join

    Hi,
    Lets say I have two tables, i.e:
    TAB_A (colA1, colA2, colA3, colA4)
    TAB_B (colB1, colB2, colB3, colB4) where colB2 is a FK to colA1
    I am after an SQL query that will cater for both the following two scenarios.
    Scenario 1:
    TAB_A has two rows of data, i.e
    (1, ABC100, 1, WG_A)
    (2, ABC100, 2, WG_B)
    TAB_B has one row of data, i.e
    (1, 1, EMP_222, 4)
    I use the following SQL:
    select a.*, b.*
    from tab_a a FULL OUTER JOIN tab_b b ON (a.colA1 = b.colB2)
    where a.colA2 = 'ABC100'
    This returns two rows:
    1, ABC100, 1, WG_A, 1, 1, EMP_222, 4
    2, ABC100, 2, WG_B
    Now, what I actually would like my query to do is actually only return the row where a tab_b record exists, i.e, should only return one record:
    1, ABC100, 1, WG_A, 1, 1, EMP_222, 4
    This I can achieve by using a RIGHT OUTER JOIN instead above, but this causes issue with my scenario 2, which is the following set-up
    Scenario 2:
    TAB_A has only one row of data this time, i.e
    (2, ABC100, 2, WG_B)
    TAB_B has no data at all this time
    This returns no rows but I actually now want this single record from tab_a returned.
    I basically require an SQL query that will cater for both the top 2 scenarios, i.e, if a tab_b record exists from the outer join then only return this record along with tab_a data. If a tab_b record doesn't exist, then only return the tab_a record.
    Hope the above makes sense.
    Thanks.

    Is it what you need (not very elegant) ?
    SQL> select * from t_outer;
            ID CODE
             1 100
             2 100
    SQL> select * from t_inner;
    no rows selected
    SQL> with tab1 as (
      2  select a.id a_id, a.code, b.id b_id from t_outer a join t_inner b on
      3  (a.id = b.id and a.code = '100'))
      4  select * from tab1
      5  union all
      6  select a.*, null from t_outer a where not exists (
      7  select 1 from tab1)
      8  and a.code = '100'
      9  /
          A_ID CODE             B_ID
             1 100
             2 100
    SQL> insert into t_inner values(2);
    1 row created.
    SQL> with tab1 as (
      2  select a.id a_id, a.code, b.id b_id from t_outer a join t_inner b on
      3  (a.id = b.id and a.code = '100'))
      4  select * from tab1
      5  union all
      6  select a.*, null from t_outer a where not exists (
      7  select 1 from tab1)
      8  and a.code = '100'
      9  /
          A_ID CODE             B_ID
             2 100                 2
    Rgds.

  • 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

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • ONLY ALLOW PRINTING ON a PDF FORM in ACROBAT 8.3

    OK I have a form that I have created that I want to only allow filling in and printing, no saving of the completed form, no emailing to the public. The catch is we dont want to password protect it. So is there a way to put a form out there that they

  • Rule settlement - finding details

    Hi eksperts I u2018ve made rule settlement for  WBS element by cjic. Where I can find my rule in details : WBS, settlement receiver, amount? My problem is, because I donu2019t remember my rule. Are some reports or table which show this information? R

  • USMT Copies Data but does not restore data.

    Can someone help me to shed some lite on a problem we are having?  I am running an OSD task in SCCM2012R2.  The Task Has the USMT option selected and enabled.  When I run the OSD task on workstation I can see it run, I can even go to the directory an

  • ISupplier Portal work flow issue

    Hi All, In iSupplier Portal, during registration (new user creation) it will call a Workflow to send notification for notifying buyers about the registration of supplier. We can see the workflow process set(named: Supplier User Registration Workflow

  • Withdrawl of material(with batch) for scrapping that shelflife passd

    Dear Guruz, in have an issue in withdrawl for scrapping with mvt type 551. But my materials are maintained in batches and the shelf life has expired. The materials are also damaged so i want to scrap them but there exist stock for those materials. ho