Union among multiple select queries with full outer join

Hello everyone,
I have 3 different select queries (used FULL Outer Join) which work fine. Now I want to add Union to the results among them and pick the selected columns from each query in the final result. while doing so, I am getting an error as "right parenthesis missing". I am quite sure, it is not the real cause. I guess might be issue with the query structure.
select j.pod, j.hostname, portal.hostname,saasc.hostname,a3s.hostname from -- * from
Select J.Pod,J.Hostname, P.Pod Portal_Pod,P.Hostname Portal_Hostname
From Total_Pod J
full outer join Portal_Tmp P On (J.Pod = P.Pod And J.Hostname = P.Hostname) as portal
Union
Select J.Pod,J.Hostname, s.Pod saasc_Pod,s.Hostname saasc_Hostname
From Total_Pod J
full outer join Saasc_Tmp S  On (J.Pod = s.Pod And J.Hostname = s.Hostname) as saasc
Union
Select J.Pod,J.Hostname, a.Pod a3s_Pod,a.Hostname a3s_Hostname
From Total_Pod J
Full Outer Join A3s_Tmp A  On (J.Pod = A.Pod And J.Hostname = A.Hostname) as a3s
)p.s: select * from (INNER QUERY); also does not work.
Any help appreciated.
Thanks in advance.

With T as
(Select J.Pod,J.Hostname, P.Pod Portal_Pod,P.Hostname Portal_Hostname
From Total_Pod J
full outer join Portal_Tmp P On (J.Pod = P.Pod And J.Hostname = P.Hostname) ),
U as
(Select J.Pod,J.Hostname, s.Pod saasc_Pod,s.Hostname saasc_Hostname
From Total_Pod J
full outer join Saasc_Tmp S  On (J.Pod = s.Pod And J.Hostname = s.Hostname) ),
V as
(Select J.Pod,J.Hostname, a.Pod a3s_Pod,a.Hostname a3s_Hostname
From Total_Pod J
Full Outer Join A3s_Tmp A  On (J.Pod = A.Pod And J.Hostname = A.Hostname) )
Select T.Pod,T.Hostname,nvl(T.Portal_Hostname,'Not Available') portal,nvl(U.Saasc_Hostname,'Not Available') saasc,NVL(V.A3s_Hostname,'Not Available') a3s From T,U,V
Where T.Pod = U.Pod
And U.Pod = V.Pod
And T.Hostname = U.Hostname
And U.Hostname = V.Hostname

Similar Messages

  • 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

  • Repalcing UNIOn with full outer Join

    I have a query wihch looks like ,
    select colA,colB ,colC, coldD from A,B,C,D
    where (some join conditions)
    union
    select colA,colB ,colC, NULL from A,B,C
    where (some join conditions)
    This query is posing us serious performance issues and we want to tune the query.
    SO to remove the UNION operator we want to use FULL JOIN.
    Can you please let us know how to frame the full outer join in the above query,so that the result set intact.
    Thanks Much

      Here goes my first query that uses UNION :
    SELECT  from_it.seq_routing,
           from_it.milestone_routing_dt,
           from_it.milestone_type_desc,
           to_it.seq_routing,
           to_it.milestone_routing_dt,
           to_it.milestone_type_desc,
           to_it.delay_flag,
           to_it.acceptable_delay_flag,
           TAB_A.calendar_minutes, TAB_A.business_minutes,
           TAB_A.due_date, TAB_A.late_minutes,
           TAB_A.delay_concat_comments,TAB_C.TAB_C_key,
           TAB_C.pcd,TAB_C.ssn,
           mmp.MEASURE_NAME,
           api.METRICS_PARAMETER_KEY,
    api.METRICS_PARAMETER_PRODUCT_KEY,
    crt.JUSTIFICATION_CD,
    crt.JUSTIFICATION_DESC,
    crt.ROUTING_USER_SITE_DESC
      FROM TAB_A, TAB_B from_it, TAB_B to_it,
      TAB_C, TAB_E,TAB_D mmp,TAB_F api, TAB_G crt
    WHERE from_it.TAB_B_key =
                                      TAB_A.from_TAB_B_key
       AND to_it.TAB_B_key =
                                        TAB_A.to_TAB_B_key
       ANDTAB_C.TAB_C_key = from_it.TAB_C_key
       andTAB_C.TAB_C_key = to_it.TAB_C_key
       and TAB_E.pck =crt.pck
       and to_it.SEQ_ROUTING  =crt.SEQ_ROUTING
       and TAB_E.pcd =TAB_C.pcd
       and TAB_E.ssn =TAB_C.ssn
       andTAB_C.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
       and TAB_A.METRICS_MEASURE_KEY =mmp.METRICS_MEASURE_KEY
       andapi.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
       andTAB_C.TAB_C_key =api.TAB_C_KEY
       andapi.PARAMETER_TYPE = 'IN'
    and TAB_A.end_dt = TO_DATE('12/31/9999', 'MM/DD/YYYY')
    and CRT.end_dt  = TO_DATE('12/31/9999', 'MM/DD/YYYY')
    UNION
    SELECT  from_it.seq_routing,
           from_it.milestone_routing_dt,
           from_it.milestone_type_desc,
           to_it.seq_routing,
           to_it.milestone_routing_dt,
           to_it.milestone_type_desc,
           to_it.delay_flag,
           to_it.acceptable_delay_flag,
           TAB_A.calendar_minutes, TAB_A.business_minutes,
           TAB_A.due_date, TAB_A.late_minutes,
           TAB_A.delay_concat_comments,TAB_C.TAB_C_key,
           TAB_C.pcd,TAB_C.ssn,
           mmp.MEASURE_NAME,
           api.METRICS_PARAMETER_KEY,
    api.METRICS_PARAMETER_PRODUCT_KEY,
    NULL, NULL, NULL
      FROM TAB_A, TAB_B from_it, TAB_B to_it,
      TAB_C, TAB_E,TAB_D mmp,TAB_F api
    WHERE from_it.TAB_B_key =
                                      TAB_A.from_TAB_B_key
       AND to_it.TAB_B_key =
                                        TAB_A.to_TAB_B_key
       ANDTAB_C.TAB_C_key = from_it.TAB_C_key
       andTAB_C.TAB_C_key = to_it.TAB_C_key
       and TAB_E.pcd =TAB_C.pcd
       and TAB_E.ssn =TAB_C.ssn
       andTAB_C.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
       and TAB_A.METRICS_MEASURE_KEY =mmp.METRICS_MEASURE_KEY
       andapi.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
       andTAB_C.TAB_C_key =api.TAB_C_KEY
       andapi.PARAMETER_TYPE = 'IN'
       and to_it.SEQ_ROUTING is null
    and TAB_A.end_dt = TO_DATE('12/31/9999', 'MM/DD/YYYY')
    And the one with OUTER JOIN used :
    SELECT  from_it.seq_routing,
           from_it.milestone_routing_dt,
           from_it.milestone_type_desc,
           to_it.seq_routing,
           to_it.milestone_routing_dt,
           to_it.milestone_type_desc,
           to_it.delay_flag,
           to_it.acceptable_delay_flag,
           TAB_A.calendar_minutes, TAB_A.business_minutes,
           TAB_A.due_date, TAB_A.late_minutes,
           TAB_A.delay_concat_comments,TAB_C.TAB_C_key,
           TAB_C.pcd,TAB_C.ssn,
           mmp.MEASURE_NAME,
           api.METRICS_PARAMETER_KEY,
    api.METRICS_PARAMETER_PRODUCT_KEY,
    crt.JUSTIFICATION_CD,
    crt.JUSTIFICATION_DESC,
    crt.ROUTING_USER_SITE_DESC
      FROM TAB_A  JOIN
      TAB_B from_it
      on  from_it.TAB_B_key =
                                      TAB_A.from_TAB_B_key
                      and TAB_A.end_dt = TO_DATE('12/31/9999', 'MM/DD/YYYY')
             JOIN
      TAB_B to_it
      ON to_it.TAB_B_key =
                                        TAB_A.to_TAB_B_key
                        JOINTAB_C
    ONTAB_C.TAB_C_key = from_it.TAB_C_key
    ANDTAB_C.TAB_C_key = to_it.TAB_C_key    
    andTAB_C.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')                
      JOINTAB_D mmp
      ON TAB_A.METRICS_MEASURE_KEY =mmp.METRICS_MEASURE_KEY
      JOIN TAB_E
      ON  TAB_E.pcd =TAB_C.pcd
       and TAB_E.ssn =TAB_C.ssn
      -- and TAB_E.ssn = 'PFEARG'
    JOINTAB_F api
    ON   TAB_C.TAB_C_key =api.TAB_C_KEY
       andapi.PARAMETER_TYPE = 'IN'
       andapi.END_DT = TO_DATE('12/31/9999', 'MM/DD/YYYY')
      LEFT

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Strange bug with Full Outer Join

    Hi guys,
    can you please confirm this behaviour on 11gR2? It used to work fine on 10gR1.
    Small test case:
    create table TEST_OBJECT_METADATA
      project_name  VARCHAR2(30 CHAR) not null,
      object_id     NUMBER not null
    create table TEST_OBJECT_INFO
      object_id          NUMBER not null,
      object_type        VARCHAR2(30) not null
    create table TEST_SUPPORTED_OBJECTS
      object_type    VARCHAR2(30 CHAR) not null,
      enabled        NUMBER(1));
    INSERT INTO TEST_OBJECT_METADATA VALUES ('NEW',1);
    INSERT INTO TEST_OBJECT_INFO VALUES (1, 'TABLE');
    INSERT INTO TEST_SUPPORTED_OBJECTS VALUES ('TABLE',1);
    COMMIT;When I execute the following query:
    WITH old_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'OLD'),
    new_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'NEW')
    SELECT src.object_type,
               t.enabled
      FROM (SELECT nvl(o.object_type, n.object_type) object_type
              FROM old_project o
              FULL OUTER JOIN new_project n
                ON o.object_id = n.object_id) src,
           test_supported_objects t
    WHERE src.object_type = t.object_type(+);I get the following output:
    OBJECT_TYPE     ENABLED
    TABLE             So, the outer join to test_supported_objects does not match.
    But if I force the FULL OUTER JOIN to run first using rownum:
    WITH old_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'OLD'),
    new_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'NEW')
    SELECT src.object_type,
               t.enabled
      FROM (SELECT nvl(o.object_type, n.object_type) object_type,
                           rownum
              FROM old_project o
              FULL OUTER JOIN new_project n
                ON o.object_id = n.object_id) src,
           test_supported_objects t
    WHERE src.object_type = t.object_type(+);I get the expected output:
    OBJECT_TYPE     ENABLED
    TABLE             1 Thanks in advance.

    Without mixing works fine:
    WITH old_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'OLD'),
    new_project AS
    (SELECT oi.object_type,
             oi.object_id
        FROM test_object_metadata om,
             test_object_info     oi
       WHERE om.object_id = oi.object_id
         AND project_name = 'NEW')
    SELECT src.object_type,
           t.enabled
      FROM (SELECT nvl(o.object_type, n.object_type) object_type
              FROM old_project o,
                   new_project n   
              where  o.object_id = n.object_id(+)
              UNION
              SELECT nvl(o.object_type, n.object_type) object_type
              FROM old_project o,
                   new_project n   
              where  o.object_id(+) = n.object_id) src,
           test_supported_objects t
    WHERE src.object_type = t.object_type(+);but there shouldn't be any restrictions on mixing them, right?

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

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

  • OWB does not allow full outer join

    I got following error (twice) while validating my mapping: "VLD-1506: Invalid Expression: Mixing full and partial outer joins in one mapping is not supported".
    I have following join conditions in my mapping:
    1) INGRP1.DISTRICT_ID = INGRP2.DISTRICT_ID And INGRP1.CHARGE_PERIOD_ID = INGRP2.CHARGE_PERIOD_ID And INGRP1.UTL_ID = INGRP2.UTL_ID
    2) The same
    3) INGRP1.CHARGE_PERIOD_ID (+) = INGRP2.CHARGE_PERIOD_ID (+) And
    INGRP1.DISTRICT_ID (+) = INGRP2.DISTRICT_ID (+) And
    INGRP1.PROVIDER# (+) = INGRP2.PROVIDER# (+)
    I suppose there is not any partial joins here. I tried to make first and second conditions with full outer joins too:
    INGRP1.DISTRICT_ID (+) = INGRP2.DISTRICT_ID (+) And
    INGRP1.CHARGE_PERIOD_ID (+) = INGRP2.CHARGE_PERIOD_ID (+) And
    INGRP1.UTL_ID (+) = INGRP2.UTL_ID (+) And
    INGRP1.DISTRICT_ID IS NOT NULL And
    INGRP2.DISTRICT_ID IS NOT NULL
    If I do this, validation reports the same error, but six times instead of twice.
    If I remove outer joins OWB generates following mapping statement:
    MERGE
    /*+ APPEND PARALLEL(MMB$ACCOUNT, DEFAULT, DEFAULT) */
    INTO
    "MMB$ACCOUNT"
    USING
    (SELECT
    /*+ NO_MERGE */
    "INGRP1"."DISTRICT_ID" "DISTRICT_ID",
    DIC$TIME_RECODER."MONTH_ID" "MONTH_ID",
    "INGRP1"."PROVIDER#" "PROVIDER#",
    "INGRP1"."ACCOUNT_NO" "ACCOUNT_NO",
    "INGRP2"."ACCOUNT_NO" "ACCOUNT_NO_1"
    FROM "DIC$TIME_RECODER" DIC$TIME_RECODER,
    (SELECT
    /*+ DRIVING_SITE("AGG"."AGG_INPUT_SUBQUERY"."FC_CHARGES_1_GKH_REL2_GKH_STAR") */
    "AGG"."CHARGE_PERIOD_ID" "CHARGE_PERIOD_ID",
    "AGG"."DISTRICT_ID$0" "DISTRICT_ID",
    "AGG"."PROVIDER#$0" "PROVIDER#",
    "AGG"."ACCOUNT_NO$0" "ACCOUNT_NO"
    FROM (SELECT
    ("AGG_INPUT_SUBQUERY"."CHARGE_PERIOD_ID$0") "CHARGE_PERIOD_ID",
    ("AGG_INPUT_SUBQUERY"."DISTRICT_ID$1") "DISTRICT_ID$0",
    ("AGG_INPUT_SUBQUERY"."PROVIDER#$1") "PROVIDER#$0",
    COUNT(DISTINCT ("AGG_INPUT_SUBQUERY"."ACCOUNT_NO$1")) "ACCOUNT_NO$0"
    FROM (SELECT
    "INGRP1"."DISTRICT_ID" "DISTRICT_ID$1",
    "INGRP1"."CHARGE_PERIOD_ID" "CHARGE_PERIOD_ID$0",
    DM_UTILITIES_1_GKH_R14554."PROVIDER#" "PROVIDER#$1",
    "FC_CHARGES_1_GKH_REL2_GKH_STAR"."ACCOUNT_NO" "ACCOUNT_NO$1"
    FROM {"FC_CHARGES"@GKH_REL2_GKH_STAR} "FC_CHARGES_1_GKH_REL2_GKH_STAR",
    {"DM_UTILITIES"@GKH_REL2_GKH_STAR} DM_UTILITIES_1_GKH_R14554,
    (SELECT
    "DEDUP"."DISTRICT_ID$2" "DISTRICT_ID",
    "DEDUP"."CHARGE_PERIOD_ID$1" "CHARGE_PERIOD_ID",
    "DEDUP"."UTL_ID" "UTL_ID"
    FROM (SELECT
    DISTINCT
    "FC_CHARGES_GKH_REL2_GKH_STAR"."DISTRICT_ID" "DISTRICT_ID$2",
    "FC_CHARGES_GKH_REL2_GKH_STAR"."CHARGE_PERIOD_ID" "CHARGE_PERIOD_ID$1",
    "FC_CHARGES_GKH_REL2_GKH_STAR"."UTL_ID" "UTL_ID"
    FROM {"FC_CHARGES"@GKH_REL2_GKH_STAR} "FC_CHARGES_GKH_REL2_GKH_STAR" WHERE ( (MAP_DIC$ACCOUNT."DATE_START") <= coalesce ( "FC_CHARGES_GKH_REL2_GKH_STAR"."CHANGED_DATE_#" , "FC_CHARGES_GKH_REL2_GKH_STAR"."CREATED_DATE_#" ) )) "DEDUP" ) "INGRP1" WHERE ( "INGRP1"."DISTRICT_ID" = "FC_CHARGES_1_GKH_REL2_GKH_STAR"."DISTRICT_ID" ) AND
    ( "INGRP1"."CHARGE_PERIOD_ID" = "FC_CHARGES_1_GKH_REL2_GKH_STAR"."CHARGE_PERIOD_ID" ) AND
    ( "INGRP1"."UTL_ID" = "FC_CHARGES_1_GKH_REL2_GKH_STAR"."UTL_ID" ) AND
    ( ( DM_UTILITIES_1_GKH_R14554."UTL_ID" (+) = "INGRP1"."UTL_ID" ) )) "AGG_INPUT_SUBQUERY"
    GROUP BY
    ("AGG_INPUT_SUBQUERY"."DISTRICT_ID$1"), ("AGG_INPUT_SUBQUERY"."CHARGE_PERIOD_ID$0"), ("AGG_INPUT_SUBQUERY"."PROVIDER#$1")) "AGG" ) "INGRP1",
    (SELECT
    /*+ DRIVING_SITE("AGG_1"."AGG_INPUT_SUBQUERY$0"."FC_PAYMENTS_1_GKH_RE143940") */
    "AGG_1"."PROVIDER#$2" "PROVIDER#",
    "AGG_1"."DISTRICT_ID$3" "DISTRICT_ID",
    "AGG_1"."CHARGE_PERIOD_ID$2" "CHARGE_PERIOD_ID",
    "AGG_1"."ACCOUNT_NO$2" "ACCOUNT_NO"
    FROM (SELECT
    ("AGG_INPUT_SUBQUERY$0"."PROVIDER#$3") "PROVIDER#$2",
    ("AGG_INPUT_SUBQUERY$0"."DISTRICT_ID$4") "DISTRICT_ID$3",
    ("AGG_INPUT_SUBQUERY$0"."CHARGE_PERIOD_ID$3") "CHARGE_PERIOD_ID$2",
    COUNT(DISTINCT ("AGG_INPUT_SUBQUERY$0"."ACCOUNT_NO$3")) "ACCOUNT_NO$2"
    FROM (SELECT
    "INGRP1"."DISTRICT_ID" "DISTRICT_ID$4",
    "INGRP1"."CHARGE_PERIOD_ID" "CHARGE_PERIOD_ID$3",
    DM_UTILITIES_GKH_REL2_GKH."PROVIDER#" "PROVIDER#$3",
    "FC_PAYMENTS_1_GKH_RE143940"."ACCOUNT_NO" "ACCOUNT_NO$3"
    FROM {"FC_PAYMENTS"@GKH_REL2_GKH_STAR} "FC_PAYMENTS_1_GKH_RE143940",
    {"DM_UTILITIES"@GKH_REL2_GKH_STAR} DM_UTILITIES_GKH_REL2_GKH,
    (SELECT
    "DEDUP_1"."DISTRICT_ID$5" "DISTRICT_ID",
    "DEDUP_1"."CHARGE_PERIOD_ID$4" "CHARGE_PERIOD_ID",
    "DEDUP_1"."UTL_ID$0" "UTL_ID"
    FROM (SELECT
    DISTINCT
    "FC_PAYMENTS_GKH_REL2_GKH_STAR"."DISTRICT_ID" "DISTRICT_ID$5",
    "FC_PAYMENTS_GKH_REL2_GKH_STAR"."CHARGE_PERIOD_ID" "CHARGE_PERIOD_ID$4",
    "FC_PAYMENTS_GKH_REL2_GKH_STAR"."UTL_ID" "UTL_ID$0"
    FROM {"FC_PAYMENTS"@GKH_REL2_GKH_STAR} "FC_PAYMENTS_GKH_REL2_GKH_STAR" WHERE ( (MAP_DIC$ACCOUNT."DATE_START") <= coalesce ( "FC_PAYMENTS_GKH_REL2_GKH_STAR"."CHANGED_DATE_#" , "FC_PAYMENTS_GKH_REL2_GKH_STAR"."CREATED_DATE_#" ) )) "DEDUP_1" ) "INGRP1" WHERE ( "INGRP1"."DISTRICT_ID" = "FC_PAYMENTS_1_GKH_RE143940"."DISTRICT_ID" ) AND
    ( "INGRP1"."CHARGE_PERIOD_ID" = "FC_PAYMENTS_1_GKH_RE143940"."CHARGE_PERIOD_ID" ) AND
    ( "INGRP1"."UTL_ID" = "FC_PAYMENTS_1_GKH_RE143940"."UTL_ID" ) AND
    ( ( DM_UTILITIES_GKH_REL2_GKH."UTL_ID" (+) = "INGRP1"."UTL_ID" ) )) "AGG_INPUT_SUBQUERY$0"
    GROUP BY
    ("AGG_INPUT_SUBQUERY$0"."DISTRICT_ID$4"), ("AGG_INPUT_SUBQUERY$0"."CHARGE_PERIOD_ID$3"), ("AGG_INPUT_SUBQUERY$0"."PROVIDER#$3")) "AGG_1" ) "INGRP2" WHERE ( "INGRP1"."CHARGE_PERIOD_ID" = "INGRP2"."CHARGE_PERIOD_ID" ) AND
    ( "INGRP1"."DISTRICT_ID" = "INGRP2"."DISTRICT_ID" ) AND
    ( "INGRP1"."PROVIDER#" = "INGRP2"."PROVIDER#" ) AND
    ( ( DIC$TIME_RECODER."PERIOD_ID" (+) = "INGRP1"."CHARGE_PERIOD_ID" ) )
    ) "MERGEQUERY_325"
    ON (
    "MMB$ACCOUNT"."DISTRICT_ID" = "MERGEQUERY_325"."DISTRICT_ID" AND
    "MMB$ACCOUNT"."MONTH_ID" = "MERGEQUERY_325"."MONTH_ID" AND
    "MMB$ACCOUNT"."PROVIDER_ID" = "MERGEQUERY_325"."PROVIDER#" )
    WHEN NOT MATCHED THEN
    INSERT
    ("MMB$ACCOUNT"."DISTRICT_ID",
    "MMB$ACCOUNT"."MONTH_ID",
    "MMB$ACCOUNT"."PROVIDER_ID",
    "MMB$ACCOUNT"."QNT_CHARGED",
    "MMB$ACCOUNT"."QNT_PAID")
    VALUES
    ("MERGEQUERY_325"."DISTRICT_ID",
    "MERGEQUERY_325"."MONTH_ID",
    "MERGEQUERY_325"."PROVIDER#",
    "MERGEQUERY_325"."ACCOUNT_NO",
    "MERGEQUERY_325"."ACCOUNT_NO_1")
    WHEN MATCHED THEN
    UPDATE
    SET
    "QNT_CHARGED" = "MERGEQUERY_325"."ACCOUNT_NO",
    "QNT_PAID" = "MERGEQUERY_325"."ACCOUNT_NO_1";
    What does it mean? Is JOINER's full outer join is incompatible with KEY LOOKUP operator and KL should be replaced with WB_LOOKUP_NUM?

    Sanders,
    Key lookup always does a partial outer join. When the full outer join and partial outer join conditions are put together, there is no available syntax to facilitate it.
    The way to this to generate the join operator (with full outer join) first in a subquery, then generate the key lookup as the outer query. Or the other way around, first the key lookup then the full outer join. The important part is that the key lookup can't be merged into the FROM-list.
    So there are two workarounds. One is what you already pointed out, using WB_LOOKUP_NUM.
    The other is to explicitly spell out the key lookup logic in the mapping by introducing a join with the lookup table, like this.
    Change
    Table1
    .......... Join (w/ foj cond.) ---> KeyLookup
    Table2
    to
    Table1
    .......... Join (w/ foj cond)
    Table2 ........................ Join (w/ poj cond.) ---> Lookup table
    Nikolai Rochnik

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

  • How to get only matching rows in Full Outer Join

    HI All,
    I was recently asked this question.
    How to fetch only matching data from two tables using Full Outer Join. Now, I understand that this is not the objective of using Full Joins but I was wondering whether this is possible or not.
    Any help in this regard will be highly appreciated.

    Full outer join returns both matching and not matching rows, if you want only matching rows why you don't use INNER JOIN?
    The following query does an INNER JOIN using a FULL JOIN which I think it doesn't make any sense.
    SELECT *
    FROM
    A FULL OUTER JOIN B
    ON A.ColumnName = B.ColumnName
    WHERE
    A.ColumnName IS NOT NULL
    AND B.ColumnName IS NOT NULL
    EntityLite: A Lightweight, Database First, Micro ORM

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

  • What's faster  - full outer join or sum a union

    Hello,
    what do you think it's the best way to bring two tables together? Full outer join (1) or sum over a union (2)?
    1.
    select a.id nvl(a.x,0) ,nvl(b.y,0) from
    a full outer join b
    where a.id=b.id
    2.
    select id, sun(x), sum(y) from
    (select id, x,0 y from a
    union all
    select id, 0 x, y from b )
    group by id;
    The ids are primary keys and ca. 80% of ids in a are found in b and vice versa.
    Both tables have about 20 mio datasets.
    Thank for thinking about
    Stephan

    Like so many things in Oracle, the answer is it depends. Various factors such as resources available (memory, CPU, disk speed etc.), size of the tables, and the indexes available will all influence the performance of a given query.
    Having said that, my guess would be that the UNION ALL query would be faster than the full outer join, since ther is less work involved. However, the optimized may be smart enough to re-write the full outer join as a union all.
    Another approach which might be worth benchmarking is:
    SELECT id, SUM(x), SUM(y)
    FROM (SELECT id, SUM(x), 0 y
          FROM a
          GROUP BY id
          UNION ALL
          SELECT id, 0, SUM(y) y
          FROM b
          GROUP BY id)HTH
    John

  • Are Multiproviders union or Full outer Joins of their InfoProviders?

    I was modeling an heterogeneous Multiprovider and thinking about the expected result set of my query. Looking at SAP note 379736, we can see that's really doing a full outer join sql operation, not an Union. Am I thinking right about that?
    Regards,
    André Rodrigues
    Edited by: André Rodrigues on Aug 3, 2011 3:03 PM

    Yes you're right, this is not really an union nor a full outer join but sometimes simplifying things can make them more understandable...
    UNION=
    Combines the results of two or more queries into a single result set that includes all the rows that belong to all queries in the union. The UNION operation is different from using joins that combine columns from two tables.
    The following are basic rules for combining the result sets of two queries by using UNION:
    The number and the order of the columns must be the same in all queries.
    The data types must be compatible.
    FULL OUTER JOIN=
    Specifies that a row from either the left or right table that does not meet the join condition is included in the result set, and output columns that correspond to the other table are set to NULL. This is in addition to all rows typically returned by the INNER JOIN.
    Quote from http://msdn.microsoft.com/en-us/library

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

  • 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

Maybe you are looking for

  • How do I save music from iPod???

    If i have to restore my iPod and i want to save all the music on it... how do i save that music so that i can restore it and then put my music back on to it???

  • Symbol Properties - changing class name

    Newbee question... I'm trying to change the class name of a movie clip symbol that I have in my library. I've changed the name of the symbol, I've change the name of the class in my AS3. I've changed the name in the advanced properties Class:, but at

  • Using signalexpress to measure temp

    Hey all, I'm using the NI USB 6259 with type E thermocouples and LabVIEW Signal Express to measure temp. avgs over a period of time. There seems to be a slow rate of response between the thermocouple and the board -- for example, if I pinch the therm

  • CS5/CS6 Crash on startup, possibly Wacom Related

    Hello everyone. I've owned a Wacom Bamboo and both versions of Photoshop for some time, and use them frequently. However, since my purchase of a Wacom Intuos5 Drawing pad yesterday and installation of it's drivers, Photoshop has failed to open- both

  • Making tarball while preserving fileorder

    Greetings I need to make a taball of a folder, of which the files are added in the alphabetical order. The correct order: $ ls -1 temp/ 2010-03-09 01-33-13-40.log 2010-03-09 01-35-08-42.log 2010-03-09 01-37-12-26.log 2010-03-09 01-39-21-06.log 2010-0