complete elimination of an outer join

Hi all

I'm reporting two fact tables. However, despite the use of inner joins only in the RPD, obiee generates a full outer joins between the two WITH (subquery factoring). Is it possible to apply inner joins.

Thank you

Surya

872073 wrote:
All in RPD joins are inner joins. The generated query is similar as follows. The full outer join is created automatically between SAWITH0 SAWITH1

WITH
SAWITH0 AS (SELECT sum (T245. QUANTITY_SOLD) AS c1,.
T161. CHANNEL_DESC AS c2
Of
SH. T161 CHANNELS,
HS SALES T245
WHERE (T161. CHANNEL_ID = T245. CHANNEL_ID)
T161 GROUP. CHANNEL_DESC),
SAWITH1 AS (SELECT sum (T168. UNIT_COST) AS c1,.
T161. CHANNEL_DESC AS c2
Of
SH. T161 CHANNELS,
HS FEES T168
WHERE (T161. CHANNEL_ID T168 =. CHANNEL_ID)
T161 GROUP. CHANNEL_DESC)
SELECT DISTINCT cases where SAWITH1.c2 IS NOT NULL, then SAWITH1.c2 when SAWITH0.c2 IS NOT NULL then SAWITH0.c2 end AS c1,
C2 SAWITH0. C1 DID,
SAWITH1. C1 AS c3
Of
SAWITH0 FULL OUTER JOIN SAWITH1 ON SAWITH0.c2 = SAWITH1.c2
ORDER BY c1

If I change the underlined FULL OUTER JOIN just preceding 'JOIN', the query returns I want.

Published by: 872073 on October 24, 2012 13:14

Check if PERF_PREFER_INTERNAL_STITCH_JOIN has been disabled in the file DB Features.ini

The path to the file is Oracle/Middleware/instances/instance1/config/OracleBIServerComponent/coreapplication_obis1/DBFeatures.INI

Tags: Business Intelligence

Similar Questions

  • outer join information

    Dear expert;

    If you look at the section of outer join. The user asserts that there is no complete equivalent in the outer join syntax. Is it true.

    http://www.Oracle-base.com/articles/9i/ANSIISOSQLSupport.php

    If this is not the case, no one knows the equivalent. Thank you

    It's true, but you can do something similar by using the UNION.

    Example of
    http://www.Oreillynet.com/network/2002/04/23/fulljoin.html

    Concerning
    Peter

  • Outer join complete Multi Table

    What is the syntax to make a full outer join on three tables. All the examples I can find use using the clause, but in my case, the column names are not the same in the three tables

    Hello

    Use IT instead of USE.

    Assuming that all the 3 tables will have a common value in a column (whatever it is called):

    ...
    FROM           table_x  x
    FULL OUTER JOIN      table_y  y     ON     y.idy     = x.idx
    FULL OUTER JOIN      table_z  z     ON     z.idz     = COALESCE (x.idx, y.idy)
    

    When comes the time to join table_z, you won't know which of the previous tables match, so you must use COALESCE to try them all.

    If you need to join several tables in this way, the expression of COALESCE for the nth table will have (n - 1) arguments.

  • Issue of OUTER JOIN

    So, for the following data:
    CREATE TABLE MOVIE
      (TK         NUMBER(10,0) primary key,
       TITLE      VARCHAR2(40),
       CODE_GENRE VARCHAR2(2));
    /
    CREATE TABLE ACTOR
      (TK NUMBER(10,0) primary key, 
       NAME VARCHAR2(40));
    /
    CREATE TABLE MOVIE_ACTOR_XREF
      (TK_MOVIE NUMBER(10,0) references movie (tk),
       TK_ACTOR NUMBER(10,0) references actor (tk));
    /
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (1,'MAN ON FIRE','D');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (2,'THE MATRIX','SF');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (3,'PEE WEE''S BIG ADVENTURE','C');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (4,'NACHO LIBRE','C');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (5,'UP','CH');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (6,'HELLRAISER','H');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (7,'BILL AND TED''S EXCELLENT ADVENTURE','C');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (8,'MEMENTO','M');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (9,'GHOST BUSTERS','C');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (10,'MUMFORD','C');
    
    INSERT INTO ACTOR (TK,NAME) VALUES (1,'DENZEL WASHINGTON');
    INSERT INTO ACTOR (TK,NAME) VALUES (2,'DAKOTA FANNING');
    INSERT INTO ACTOR (TK,NAME) VALUES (3,'KEANU REAVES');
    INSERT INTO ACTOR (TK,NAME) VALUES (4,'PEE WEE HERMAN');
    INSERT INTO ACTOR (TK,NAME) VALUES (5,'JACK BLACK');
    INSERT INTO ACTOR (TK,NAME) VALUES (6,'ED ASNER');
    INSERT INTO ACTOR (TK,NAME) VALUES (7,'PINHEAD');
    INSERT INTO ACTOR (TK,NAME) VALUES (8,'GUY PIERCE');
    INSERT INTO ACTOR (TK,NAME) VALUES (9,'BILL MURRAY');
    INSERT INTO ACTOR (TK,NAME) VALUES (10,'DAN AKROYD');
    INSERT INTO ACTOR (TK,NAME) VALUES (11,'JASON LEE');
    
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (1,1);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (1,2);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (2,3);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (3,4);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (4,5);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (5,6);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (6,7);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (7,3);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (8,8);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (9,9);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (9,10);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (10,11);
    Why the following 2 queries do not produce the same results? The FILM table is the table of LEFTermost in outer joins, so I thought I could place criteria against it in the FROM clause and ending up with the same result:
    select m.title, m.code_genre, a.name
    from movie m
         left outer 
           join movie_actor_xref x on (m.tk = x.tk_movie
                                  and m.code_genre = 'C')
         left outer
           join actor a on (x.tk_actor = a.tk);
           
    select m.title, m.code_genre, a.name
    from movie m
         left outer 
           join movie_actor_xref x on (m.tk = x.tk_movie)
         left outer
           join actor a on (x.tk_actor = a.tk)
    where m.code_genre = 'C';
    Thank you
    -= Chuck

    Hi, Chuck,

    chuckers wrote:
    So, for the following data:

    CREATE TABLE MOVIE
    (TK         NUMBER(10,0) primary key,
    TITLE      VARCHAR2(40),
    CODE_GENRE VARCHAR2(2));
    /
    CREATE TABLE ACTOR
    (TK NUMBER(10,0) primary key,
    NAME VARCHAR2(40));
    /
    CREATE TABLE MOVIE_ACTOR_XREF
    (TK_MOVIE NUMBER(10,0) references movie (tk),
    TK_ACTOR NUMBER(10,0) references actor (tk));
    /
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (1,'MAN ON FIRE','D');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (2,'THE MATRIX','SF');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (3,'PEE WEE''S BIG ADVENTURE','C');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (4,'NACHO LIBRE','C');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (5,'UP','CH');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (6,'HELLRAISER','H');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (7,'BILL AND TED''S EXCELLENT ADVENTURE','C');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (8,'MEMENTO','M');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (9,'GHOST BUSTERS','C');
    INSERT INTO MOVIE (TK,TITLE,CODE_GENRE) VALUES (10,'MUMFORD','C');
    
    INSERT INTO ACTOR (TK,NAME) VALUES (1,'DENZEL WASHINGTON');
    INSERT INTO ACTOR (TK,NAME) VALUES (2,'DAKOTA FANNING');
    INSERT INTO ACTOR (TK,NAME) VALUES (3,'KEANU REAVES');
    INSERT INTO ACTOR (TK,NAME) VALUES (4,'PEE WEE HERMAN');
    INSERT INTO ACTOR (TK,NAME) VALUES (5,'JACK BLACK');
    INSERT INTO ACTOR (TK,NAME) VALUES (6,'ED ASNER');
    INSERT INTO ACTOR (TK,NAME) VALUES (7,'PINHEAD');
    INSERT INTO ACTOR (TK,NAME) VALUES (8,'GUY PIERCE');
    INSERT INTO ACTOR (TK,NAME) VALUES (9,'BILL MURRAY');
    INSERT INTO ACTOR (TK,NAME) VALUES (10,'DAN AKROYD');
    INSERT INTO ACTOR (TK,NAME) VALUES (11,'JASON LEE');
    
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (1,1);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (1,2);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (2,3);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (3,4);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (4,5);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (5,6);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (6,7);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (7,3);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (8,8);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (9,9);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (9,10);
    INSERT INTO MOVIE_ACTOR_XREF (TK_MOVIE,TK_ACTOR) VALUES (10,11);
    

    Thanks for posting the CREATE TABLE and INSERT! It is very useful.

    Why the following 2 queries do not produce the same results? The FILM table is the table of LEFTermost in outer joins, so I thought I could place criteria against it in the FROM clause and ending up with the same result:

    We will call this first request 'Query 1.

    select m.title, m.code_genre, a.name
    from movie m
    left outer
    join movie_actor_xref x on (m.tk = x.tk_movie
    and m.code_genre = 'C')
    left outer
    join actor a on (x.tk_actor = a.tk);
    

    Left outer joins ensure that each row of the table to move will appear in the output.
    If movie.code_genre = 'C', then he might have a match in movie_actor_xref.
    If movie.code_genre! = 'C' (or NULL) then it will not be considered to match any line in movie_actor_xref, but since it is an outer join, that the rank of the film appears in the result set.

    Let's call the other "Application 2" quuery

    select m.title, m.code_genre, a.name
    from movie m
    left outer
    join movie_actor_xref x on (m.tk = x.tk_movie)
    left outer
    join actor a on (x.tk_actor = a.tk)
    where m.code_genre = 'C';
    

    When all the joins are finsihed, all lines of film will be in the result set, if it corresponds to what in the other tables.
    Unlike the query 1, 2 the query has a WHERE clause. You can think of the WHERE clause as being applied after all the joins are completed. The WHERE clause in the query 2 will remove all the lines where movie.code_genre! = 'C' (or NULL), so the final results will not include necessarily all movie lines.

    Let's look at a specific example.
    This line appears in the output of query 1:

    TITLE                CO NAME
    -------------------- -- --------------------
    UP                   CH
    

    but there is no line of corresoponding in query output 2. Why not? What is the difference between Query1 and Query2? The difference is the condition of wheher "where m.code_genre = 'C'" applies to one of the outer joins (as in the query 1) or the game (as in query 2) set of results.
    Try to run this query, I'll call the query 0 because it contains less query 1 or 2 of the query:

    select m.title, m.code_genre, a.name
    from movie m
         left outer
           join movie_actor_xref x on (m.tk = x.tk_movie)
         left outer
           join actor a on (x.tk_actor = a.tk)
    ;
    

    Note that the query 0 does not speak code_genrel; It contains only the code that is used by query 1 and query 2. 0 query output includes this line:

    TITLE                CO NAME
    -------------------- -- --------------------
    UP                   CH ED ASNER
    

    Query 1 produces a line of title = 'UP' but that line had a NULL value in the name column. This is because the query 1 was a condition of additional join between the film and actor_movie_xref. In query 1, lines of these two tables were regarded as a match only if movie.cide_genre =' it. The line with title = 'UP' a 'CH' code_genre, so it is not considered a match with actor_movie_xref. Since it is an outer join, however, the line stays in the result set, but the columns that would be provided by actor_move_xref are all NULL. 1 query is an outer join to the table of the actor. "Join condition"x.tk_actor = a.tk"fails, because x.tk_actor is null (all x columns have NULL value) on the title line =" upward ", but, again, since it is an outer join, this line is in the result set.

    The difference between the 0 and 2 of the query request is 2 query has a WHERE clause. When the query 2 finishes to make all joins, but before she applies the WHERE clause, its result set is identical to the query result 0 set, including a line with title = 'UP '. Then the WHERE clause is applied, and any line that doesn't have a 'C' for his code_genre is eliminated.

    Published by: Frank Kulash, October 13, 2011 15:44
    Added example 'UP '.

  • BAD RESULTS WITH OUTER JOINS AND TABLES WITH A CHECK CONSTRAINT

    HII All,
    Could any such a me when we encounter this bug? Please help me with a simple example so that I can search for them in my PB.


    Bug:-8447623

    Bug / / Desc: BAD RESULTS WITH OUTER JOINS AND TABLES WITH a CHECK CONSTRAINT


    I ran the outer joins with check queries constraint 11G 11.1.0.7.0 and 10 g 2, but the result is the same. Need to know the scenario where I will face this bug of your experts and people who have already experienced this bug.


    Version: -.
    SQL> select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0      Production
    TNS for Solaris: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production

    Why do you not use the description of the bug test case in Metalink (we obviously can't post it here because it would violate the copyright of Metalink)? Your test case is not a candidate for the elimination of the join, so he did not have the bug.

    Have you really read the description of the bug in Metalink rather than just looking at the title of the bug? The bug itself is quite clear that a query plan that involves the elimination of the join is a necessary condition. The title of bug nothing will never tell the whole story.

    If you try to work through a few tens of thousands of bugs in 11.1.0.7, of which many are not published, trying to determine whether your application would be affected by the bug? Wouldn't be order of magnitude easier to upgrade the application to 11.1.0.7 in a test environment and test the application to see what, if anything, breaks? Understand that the vast majority of the problems that people experience during an upgrade are not the result of bugs - they are the result of changes in behaviour documented as changes in query plans. And among those who encounter bugs, a relatively large fraction of the new variety. Even if you have completed the Herculean task of verifying each bug on your code base, which would not significantly easier upgrade. In addition, at the time wherever you actually performed this analysis, Oracle reportedly released 3 or 4 new versions.

    And at this stage would be unwise to consider an upgrade to 11.2?

    Justin

  • Bug with an outer join, or & Analytics function (or rownum)

    Hello

    Seems to be a combination of an outer join, OR and rownum confuses the CBO.

    First request is without rownum, the second is with rownum.

    The second query expects 203 t lines and never ends. It should behave the same as query 1, with 24 M lines.

    Remove the GOLD clause query 2 allows him to behave as a query 1, with 24 M lines.

    We never saw it? Is there a solution?

    SELECT *
      FROM message i
      LEFT JOIN (SELECT hi.message_id, hi.update_dt
                   FROM message_hist hi) h ON (t.id = h.master_id
                                           AND(t.update_dt = h.update_dt OR h.update_dt <TO_DATE('150901','RRMMDD')));
          
    -----------------------------------------------------------------------------------------------                                                                                                                                                                                                              
    | Id  | Operation           | Name                    | Rows  | Bytes | Cost (%CPU)| Time     |                                                                                                                                                                                                              
    -----------------------------------------------------------------------------------------------                                                                                                                                                                                                              
    |   0 | SELECT STATEMENT    |                         |    24M|    13G|   475G  (2)|999:59:59 |                                                                                                                                                                                                              
    |   1 |  NESTED LOOPS OUTER |                         |    24M|    13G|   475G  (2)|999:59:59 |                                                                                                                                                                                                              
    |   2 |   TABLE ACCESS FULL | MESSAGE                 |  8037K|  1318M| 29883   (2)| 00:06:59 |                                                                                                                                                                                                              
    |   3 |   VIEW              |                         |     3 |  1302 | 59136   (2)| 00:13:48 |                                                                                                                                                                                                              
    |*  4 |    TABLE ACCESS FULL| MESSAGE_HIST            |     3 |   168 | 59136   (2)| 00:13:48 |                                                                                                                                                                                                              
    -----------------------------------------------------------------------------------------------                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                 
    Predicate Information (identified by operation id):                                                                                                                                                                                                                                                          
    ---------------------------------------------------                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                 
       4 - filter("I"."MESSAGE_ID"="HI"."MESSAGE_ID" AND                                                                                                                                                                                                                                                         
                  ("HI"."UPDATE_DT"<TO_DATE('150901','RRMMDD') OR "I"."UPDATE_DT"="HI"."UPDATE_DT"))     
    ----------------              
    SELECT *
      FROM message i
      LEFT JOIN (SELECT hi.message_id, hi.update_dt
                      , ROWNUM
                   FROM message_hist hi) h ON (t.id = h.master_id
                                           AND(t.update_dt = h.update_dt OR h.update_dt <TO_DATE('150901','RRMMDD')));
         
    -------------------------------------------------------------------------------------------------                                                                                                                                                                                                            
    | Id  | Operation             | Name                    | Rows  | Bytes | Cost (%CPU)| Time     |                                                                                                                                                                                                            
    -------------------------------------------------------------------------------------------------                                                                                                                                                                                                            
    |   0 | SELECT STATEMENT      |                         |   203T|   112P|   475G  (2)|999:59:59 |                                                                                                                                                                                                            
    |   1 |  NESTED LOOPS OUTER   |                         |   203T|   112P|   475G  (2)|999:59:59 |                                                                                                                                                                                                            
    |   2 |   TABLE ACCESS FULL   | MESSAGE                 |  8037K|  1318M| 29883   (2)| 00:06:59 |                                                                                                                                                                                                            
    |   3 |   VIEW                |                         |    25M|    10G| 59151   (2)| 00:13:49 |                                                                                                                                                                                                            
    |*  4 |    VIEW               |                         |    25M|    10G| 59151   (2)| 00:13:49 |                                                                                                                                                                                                            
    |   5 |     COUNT             |                         |       |       |            |          |                                                                                                                                                                                                            
    |   6 |      TABLE ACCESS FULL| MESSAGE_HIST            |    25M|  1355M| 59151   (2)| 00:13:49 |                                                                                                                                                                                                            
    -------------------------------------------------------------------------------------------------                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                 
    Predicate Information (identified by operation id):                                                                                                                                                                                                                                                          
    ---------------------------------------------------                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                 
       4 - filter("I"."MESSAGE_ID"="H"."MESSAGE_ID" AND ("I"."UPDATE_DT"="H"."UPDATE_DT" OR                                                                                                                                                                                                                          
                  "H"."UPDATE_DT"<TO_DATE('150901','RRMMDD')))         
     
    

    RowNum in a subquery is supposed to ensure that the subquery is evaluated completely before filtering, otherwise, how could you go out rownum?

    Your question is compounded because of the join condition that forces a level of nested loops, which means that the table should be fully analysed once for each line of conduct rowsource. You can either transform the join in an equijoin and allow a hash to run, or you join could materialize the subquery once.

    Allow the hash join:

    SELECT count (*)

    Message FROM

    LEFT JOIN (SELECT hi.message_id, hi.update_dt

    ROWNUM

    OF message_hist salvation) PM ON (i.message_id = h.message_id

    AND i.update_dt = h.update_dt)

    LEFT JOIN (SELECT hi.message_id, hi.update_dt

    ROWNUM

    OF message_hist salvation) h2 ON (i.message_id = h2.message_id

    AND h2.update_dt<>

    AND h2.update_dt <> i.update_dt)

    /

    ----------------------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

    ----------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |              |     1.    66.   211 (1) | 00:00:01 |

    |   1.  GLOBAL TRI |              |     1.    66.            |          |

    |*  2 |   EXTERNAL RIGHT HASH JOIN |              |   800 | 52800 |   211 (1) | 00:00:01 |

    |*  3 |    VIEW                 |              |     1.    22.    70 (0) | 00:00:01 |

    |   4.     COUNTY |              |       |       |            |          |

    |   5.      TABLE ACCESS FULL | MESSAGE_HIST |     1.    22.    70 (0) | 00:00:01 |

    |*  6 |    EXTERNAL RIGHT HASH JOIN |              |   800 | 35200.   141 (1) | 00:00:01 |

    |   7.     VIEW                |              |     1.    22.    70 (0) | 00:00:01 |

    |   8.      COUNTY |              |       |       |            |          |

    |   9.       TABLE ACCESS FULL | MESSAGE_HIST |     1.    22.    70 (0) | 00:00:01 |

    |  10.     TABLE ACCESS FULL | MESSAGE |   800 | 17600 |    70 (0) | 00:00:01 |

    ----------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    2 - access("I".") MESSAGE_ID '= 'H2'.' MESSAGE_ID "(+))"

    filter ("H2". "UPDATE_DT" (+)<>'I'. " ("' UPDATE_DT")

    3 - filter("H2".") UPDATE_DT "(+)<>

    6 - access("I".") "UPDATE_DT" ="H" UPDATE_DT "(+) AND"

    "I"." ' MESSAGE_ID ' ="H" MESSAGE_ID "(+))"

    Materialize the subquery:

    WITH h AS (SELECT / * + MATERIALIZE * / hi.message_id, hi.update_dt)

    ROWNUM

    OF message_hist salvation)

    SELECT count (*)

    Message FROM

    LEFT JOIN: ON (i.message_id = h.message_id

    AND (i.update_dt = h.update_dt OR h.update_dt<>

    ----------------------------------------------------------------------------------------------------------

    | ID | Operation | Name                        | Lines | Bytes | Cost (% CPU). Time |

    ----------------------------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |                             |     1.    22.  1740 (0) | 00:00:01 |

    |   1.  TRANSFORMATION OF THE TEMPORARY TABLE.                             |       |       |            |       |

    |   2.   LOAD SELECT ACE | SYS_TEMP_0FD9D6810_5B8F6E67 |       |       |            |       |

    |   3.    COUNT                   |                             |       |       |            |       |

    |   4.     TABLE ACCESS FULL | MESSAGE_HIST |     1.    22.    70 (0) | 00:00:01 |

    |   5.   GLOBAL TRI |                             |     1.    22.            |       |

    |   6.    NESTED EXTERNAL LOOPS |                             |   800 | 17600 |  1670 (0) | 00:00:01 |

    |   7.     TABLE ACCESS FULL | MESSAGE |   800 | 17600 |    70 (0) | 00:00:01 |

    |   8.     VIEW                   |                             |     1.       |     2 (0) | 00:00:01 |

    |*  9 |      VIEW                  |                             |     1.    22.     2 (0) | 00:00:01 |

    |  10.       TABLE ACCESS FULL | SYS_TEMP_0FD9D6810_5B8F6E67 |     1.    22.     2 (0) | 00:00:01 |

    ----------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    9 - filter("I".") ' MESSAGE_ID ' ="H" MESSAGE_ID' AND ('I'. "" "UPDATE_DT"="H" UPDATE_DT' OR

    "H"." UPDATE_DT ".<>

    You may need to change the first condition to make sure that you select the correct subquery.

    -edit

    Not able to view a plan but you can invade the second join condition select and then the result of a subquery with a predicate according to your requirement. This should delay the or rating and leave only an equijoin (although rowsource return may be slightly larger than the opposite).

    -Second edition, it did not work exactly when I tried it.

    A hybrid of the previous two plans with a slight modification of how he was imitating the GOLD:

    WITH h AS (SELECT / * + MATERIALIZE * / hi.message_id, hi.update_dt)

    ROWNUM Clotilde

    OF message_hist salvation)

    SELECT i.MESSAGE_ID

    i.UPDATE_DT

    COALESCE(h.message_id,h2.message_id) message_id

    , COALESCE (h.update_dt, h2.update_dt) update_dt

    Clotilde COALESCE (h.rown, h2.rown)

    Message FROM

    LEFT JOIN: ON (i.message_id = h.message_id

    AND i.update_dt = h.update_dt)

    LEFT JOIN: h2 WE (DECODE(h.message_id,,i.message_id) = h2.message_id - only try this if previous join returned NULL

    AND h2.update_dt<>

    /

    --------------------------------------------------------------------------------------------------------
    | ID | Operation | Name                      | Lines | Bytes | Cost (% CPU). Time |
    --------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT |                           |     1.    66.     8 (0) | 00:00:01 |
    |   1.  TRANSFORMATION OF THE TEMPORARY TABLE.                           |       |       |            |          |
    |   2.   LOAD SELECT ACE | SYS_TEMP_0FD9D6605_28F27F |       |       |            |          |
    |   3.    COUNT                   |                           |       |       |            |          |
    |   4.     TABLE ACCESS FULL | MESSAGE_HIST |   150.  3300 |     2 (0) | 00:00:01 |
    |   5.   GLOBAL TRI |                           |     1.    66.            |          |
    |*  6 |    EXTERNAL RIGHT HASH JOIN |                           | 10497.   676K |     6 (0). 00:00:01 |
    |*  7 |     VIEW                   |                           |   150.  3300 |     2 (0) | 00:00:01 |
    |   8.      TABLE ACCESS FULL | SYS_TEMP_0FD9D6605_28F27F |   150.  3300 |     2 (0) | 00:00:01 |
    |*  9 |     OUTER HASH JOIN |                           |   328. 14432 |     4 (0) | 00:00:01 |
    |  10.      TABLE ACCESS FULL | MESSAGE |   200 |  4400 |     2 (0) | 00:00:01 |
    |  11.      VIEW                  |                           |   150.  3300 |     2 (0) | 00:00:01 |
    |  12.       TABLE ACCESS FULL | SYS_TEMP_0FD9D6605_28F27F |   150.  3300 |     2 (0) | 00:00:01 |
    --------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):
    ---------------------------------------------------

    6 - access("H2".") MESSAGE_ID "(+) = DECODE (TO_CHAR ('H'". "))" MESSAGE_ID"), NULL, 'I '. (("' MESSAGE_ID '))
    7 - filter("H2".") UPDATE_DT "(+)<>
    9 - access("I".") "UPDATE_DT" ="H" UPDATE_DT "(+) AND 'I'." "" ' MESSAGE_ID '="H" MESSAGE_ID "(+))"

    (This plan is another system if costs are not comparable)

  • Outer joins to the left... Please help!

    Hmm. Ive had trouble with this one for a while and have read and re-read docs etc.

    IM under 11.2 XE and its Apex 4.2 application...

    Its a simple query with outer joins... but I can't simply to do it right after several hours of trying! ID be very grateful if anyone can lend a hand...

    For the query below. I am looking for the following:

    Complete list of entities, a sum of the values if they exist (and obviously empty if they don't), filtered by a table of SUM choice only the records that match a value in the lookup table.

    Select

    e.ENTITY as ENTITY,

    Sum (p.amount) as Forecast_Income,

    Sum (BR.bri_credit) as Actual_Income,

    Sum (BR.bri_debit) as Actual_Expenses

    Of

    e entities

    LEFT OUTER JOIN payments p

    WE (e.entity_id = p.entity_id)

    LEFT OUTER JOIN pmt_stat_lookup ps

    WE (p.status_id = ps.status_id

    and ps.forecast = 'Y')

    LEFT OUTER JOIN bri_recon br

    WE (e.entity_id = br.entity_id)

    E.entity group

    My problem with the join where I join p.status_id for ps.status_id and ps.forecast = 'Y '...   If I run the above statement, it seems does not account for this filter criteria and summarizes all records of PAYMENTS, regardless of...  If I move outside the outer join clause, it only brings back the records of PAYMENTS where there is a join. Ive tried to join in a different order etc... but in vain...

    If someone could help, Id be very grateful.

    Kind regards

    Richard

    Hello Richard

    Try this query:

    SELECT e.entity as ENTITY

    sum (PO.amount) as Forecast_Income

    sum (br.bri_credit) as Actual_Income

    sum (br.bri_debit) as Actual_Expenses

    Of

    E ENTITIES

    LEFT OUTER

    JOIN (SELECT P.entity_id )

    P.amount

    PAYMENTS P

    JOIN PMT_STAT_LOOKUP PS

    ON p.status_id = ps.status_id

    AND ps.forecast = 'Y '.

    ) IN.

    WE e.entity_id = in. entity_id

    LEFT OUTER

    JOIN BR BRI_RECON

    ON e.entity_id = br.entity_id

    E.entity GROUP

    ;

    I hope it helps.

    Best regards, David

    Post edited by: David Berger

  • need help with outer join filter.

    Need a little help to filter a result set and I can't seem to find a good way to do this.
    /*table*/
    
    create table invoice( farinvc_invh_code varchar2(100),
                                  farinvc_item varchar2(100),
                                  farinvc_po varchar2(100)
                                  )
       create table po( 
            supplier_number varchar2(60),
            supplier_invoice_no varchar2(60),
            po_number varchar2(60),
            run_date varchar2(60),
            PO_LINE_NUMBER varchar2(60) );
    /*data*/
    
    INSERT INTO "INVOICE" (FARINVC_INVH_CODE, FARINVC_ITEM, FARINVC_PO_ITEM) VALUES ('I0554164', '1', 'P0142245');
    INSERT INTO "INVOICE" (FARINVC_INVH_CODE, FARINVC_ITEM, FARINVC_PO_ITEM) VALUES ('I0554164', '3', 'P0142245');
    INSERT INTO "INVOICE" (FARINVC_INVH_CODE, FARINVC_ITEM, FARINVC_PO) VALUES ('I0554165', '1', 'P0142246');
    INSERT INTO "INVOICE" (FARINVC_INVH_CODE, FARINVC_ITEM, FARINVC_PO) VALUES ('I0554165', '2', 'P0142246');
    
    
    
    
    
    INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100121', '529132260', 'P0142245', '21-NOV-12', '1');
    INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100121', '529137831', 'P0142245', '21-NOV-12', '3');
    INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100121', '529137831', 'P0142245', '21-NOV-12', '2');
    INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100122', '145678', 'P0142246', '22-NOV-12', '1');
    INSERT INTO "PO" (SUPPLIER_NUMBER, SUPPLIER_INVOICE_NO, PO_NUMBER, RUN_DATE, PO_LINE_NUMBER) VALUES ('914100122', '145679', 'P0142246', '22-NOV-12', '2');
    query execution of im.

    SELECT  farinvc_invh_code,
                    supplier_number,
                    supplier_invoice_no,
                    farinvc_item, 
                    farinvc_po ,
                    po_number,
                    run_date,
                    PO_LINE_NUMBER
            FROM INVOICE, PO
            WHERE PO_NUMBER = FARINVC_PO(+)
            AND FARINVC_ITEM(+) = PO_LINE_NUMBER
            
    result
    "FARINVC_INVH_CODE"           "SUPPLIER_NUMBER"             "SUPPLIER_INVOICE_NO"         "FARINVC_ITEM"                "FARINVC_PO"                  "PO_NUMBER"                   "RUN_DATE"                    "PO_LINE_NUMBER"              
    "I0554165"                    "914100122"                   "145678"                      "1"                           "P0142246"                    "P0142246"                    "22-NOV-12"                   "1"                           
    "I0554165"                    "914100122"                   "145679"                      "2"                           "P0142246"                    "P0142246"                    "22-NOV-12"                   "2"                           
    "I0554164"                    "914100121"                   "529132260"                   "1"                           "P0142245"                    "P0142245"                    "21-NOV-12"                   "1"                           
    "I0554164"                    "914100121"                   "529137831"                   "3"                           "P0142245"                    "P0142245"                    "21-NOV-12"                   "3"                           
    ""                            "914100121"                   "529137831"                   ""                            ""                            "P0142245"                    "21-NOV-12"                   "2"                           
    It is a much larger table, and I took an excerpt in order to keep things clear and understanding. I would like to filter the result set to only show lines that have po numbers are the same and line are the same but there is an additional element. in other words as such.
    "FARINVC_INVH_CODE"           "SUPPLIER_NUMBER"             "SUPPLIER_INVOICE_NO"         "FARINVC_ITEM"                "FARINVC_PO"                  "PO_NUMBER"                   "RUN_DATE"                    "PO_LINE_NUMBER"              
    "I0554164"                    "914100121"                   "529132260"                   "1"                           "P0142245"                    "P0142245"                    "21-NOV-12"                   "1"                           
    "I0554164"                    "914100121"                   "529137831"                   "3"                           "P0142245"                    "P0142245"                    "21-NOV-12"                   "3"                           
    ""                            "914100121"                   "529137831"                   ""                            ""                            "P0142245"                    "21-NOV-12"                   "2"                           

    Hello

    Let me assure you that I understand.
    Last time, we were looking for the PO_NUMBERs who have been partially put into correspondence , i.e. groups of rows in the order table with the same po_number, which some had corresponding lines in the table Bill, and some of whom have not. It was essential that there is at least 1 line and 1 row without connections with the same purchase order.
    Now that you are interested SUPPLIER_INVOICE_NOs who are partially paired, i.e. groups of rows in the table of po with the same po_number and supplier_invoice_no, some of which have corresponding lines in the invoice table, and some are not. ("Supplier_Invoice_No" is quite a mouthful. "We'll abbreviate as sin in the future.) However, the final selection is based on po_numbers: If a po_number has partially matched sins, then we are interested all po_number. For example, the result set must include = 529132260 SIN, even if that sin is completely, because there is a partially matching sin (529137831) with the same po_number (P0142245).

    As this problem revolves around partially matching sins, let's call them Cardinal sins . We can calculate match_cnt and total_cnt based NAS as well as po_number. Then, we can use another analytic function so see if the po_number has all cardinal_sins, like this:

    WITH    joined_data     AS
    (
         SELECT     i.farinvc_invh_code
         ,     p.supplier_number
         ,     p.supplier_invoice_no
         ,     i.farinvc_item
         ,     i.farinvc_po
         ,     p.po_number
         ,     p.run_date
         ,     p.po_line_number
         ,     COUNT (i.farinvc_po) OVER ( PARTITION BY  p.po_number
                                            ,                  p.supplier_invoice_no
                               )     AS match_cnt
         ,     COUNT (*)           OVER ( PARTITION BY  p.po_number
                                            ,                  p.supplier_invoice_no
                                          )     AS total_cnt
         FROM           po       p
         LEFT OUTER JOIN  invoice  i  ON   i.farinvc_po    = p.po_number
                                      AND  i.farinvc_item  = p.po_line_number
    )
    ,     got_cardinal_sin_cnt     AS
    (
         SELECT  joined_data.*
         ,     SUM ( CASE
                        WHEN  match_cnt  >= 1
                     AND     match_cnt  <  total_cnt
                     THEN  1
                    END
                  ) OVER (PARTITION BY  po_number)     AS cardinal_sin_cnt
         FROM    joined_data
    )
    SELECT    farinvc_invh_code
    ,       supplier_number
    ,       supplier_invoice_no
    ,       farinvc_item
    ,       farinvc_po
    ,       po_number
    ,       run_date
    ,       po_line_number
    FROM       got_cardinal_sin_cnt
    WHERE       cardinal_sin_cnt     > 0
    ORDER BY  po_number
    ,            farinvc_item
    ;
    
  • Outer join without outer join

    I'm trying to do is to learn how to do an outer join without specifying the outer join complete, right or left. Why? For most of the reasons for performance and gain a better understanding of the Oracle.
    Thank you

    Charles.

    Another option would be a scalar subquery in the select part, as:

    SQL> select * from t;
    
            ID DESCR
    ---------- ----------
             1 T One
             2 T Two
             3 T Three
    
    SQL> select * from t1;
    
            ID DESCR
    ---------- ----------
             1 T1 One
             2 T1 Two
    
    SQL> select t.*, t1.descr t1_descr
      2  from t
      3     left join t1
      4        on t.id = t1.id;
    
            ID DESCR      T1_DESCR
    ---------- ---------- ----------
             1 T One      T1 One
             2 T Two      T1 Two
             3 T Three
    
    SQL> select t.*, (select t1.descr
      2               from t1
      3               where t.id = t1.id) t1_descr
      4  from t;
    
            ID DESCR      T1_DESCR
    ---------- ---------- ----------
             1 T One      T1 One
             2 T Two      T1 Two
             3 T Three
    

    This can be faster if the correlated T1 column is indexed, and there is a "large" number of records in t which do not correspond with t1.

    John

  • How create/update files when the original Version is based on a query of outer join?

    Hi gurus,


    I created a custom page where I use a table-style area where I question my VO records, based on a query of outer join. This query contains my table looks, where I would like to insert/update records, and joined the table of standard elements, which is external with my custom table.

    When I now question my files in the t, I have a record for each record in the table section, which is ok, but when I 'Refresh' some fields of my custom table and attempt to commit, I get the message "unable to complete the transaction on record. Cause: The record has been deleted by another user. "Action: cancel the transaction and re - query records to get new data.
    The reason why because a record is to be inserted rather than updating because in fact there is not yet in my custom table.

    The reason why I'm using the outer join, is because I don't want the user to create a record for each item one by one.
    There is no work around for this?

    Thanks in advance!


    BR
    Guy

    Hello
    You can try this.

    In your EntityImpl.java to extend OAPlsqlEntityImpl.

    Override the updateRow() method and coding your insert statement to insert into a table custom here.
    Don't forget, you must ignore the lines for which your custom table columns are null

    -Idris

  • Different Outer Join query result

    Hi all

    Under query gives the expected result


    Select DECODE (FPOVR. PROFILE_OPTION_VALUE,
    NULL, FPOVS. PROFILE_OPTION_VALUE, FPOVR. ZZ PROFILE_OPTION_VALUE)
    OPS FND_PROFILE_OPTIONS, FND_PROFILE_OPTION_VALUES FPOVR,.
    FND_PROFILE_OPTION_VALUES FPOVS where 1 = 1 and FPOVS. LEVEL_ID (+) = 10001
    and FPOVS. LEVEL_VALUE (+) = 0
    and FPOVS. PROFILE_OPTION_ID (+) IS FRENCH POLYNESIA. PROFILE_OPTION_ID
    and FPOVR. (+) LEVEL_ID = 10003 and FPOVR. LEVEL_VALUE (+) = 21533
    and FPOVR. PROFILE_OPTION_ID (+) IS FRENCH POLYNESIA. PROFILE_OPTION_ID
    and fpo.profile_option_name = 'GL_SET_OF_BKS_ID. '


    But the following query does not give the expected result.


    Select DECODE (FPOVR. PROFILE_OPTION_VALUE,
    NULL, FPOVS. PROFILE_OPTION_VALUE, FPOVR. ZZ PROFILE_OPTION_VALUE)
    OPS FND_PROFILE_OPTIONS, FND_PROFILE_OPTION_VALUES FPOVR,.
    FND_PROFILE_OPTION_VALUES FPOVS where 1 = 1 and FPOVS. LEVEL_ID (+) = 10001
    and FPOVS. LEVEL_VALUE (+) = 0
    and FPOVS. PROFILE_OPTION_ID (+) IS FRENCH POLYNESIA. PROFILE_OPTION_ID
    and FPOVR. (+) LEVEL_ID = 10003 and FPOVR. LEVEL_VALUE = 21533
    and FPOVR. PROFILE_OPTION_ID (+) IS FRENCH POLYNESIA. PROFILE_OPTION_ID
    and fpo.profile_option_name = 'GL_SET_OF_BKS_ID. '

    Difference between them is a join with external FPOVR. LEVEL_VALUE and hard coded value. Why these query above return different results even if the outer join is made with hard coded in value?

    Thank you
    SK

    SK says:
    Hi all

    Under query gives the expected result

    Select DECODE (FPOVR. PROFILE_OPTION_VALUE,
    NULL, FPOVS. PROFILE_OPTION_VALUE, FPOVR. ZZ PROFILE_OPTION_VALUE)
    OPS FND_PROFILE_OPTIONS, FND_PROFILE_OPTION_VALUES FPOVR,.
    FND_PROFILE_OPTION_VALUES FPOVS where 1 = 1 and FPOVS. LEVEL_ID (+) = 10001
    and FPOVS. LEVEL_VALUE (+) = 0
    and FPOVS. PROFILE_OPTION_ID (+) IS FRENCH POLYNESIA. PROFILE_OPTION_ID
    and FPOVR. (+) LEVEL_ID = 10003 and FPOVR. LEVEL_VALUE (+) = 21533
    and FPOVR. PROFILE_OPTION_ID (+) IS FRENCH POLYNESIA. PROFILE_OPTION_ID
    and fpo.profile_option_name = 'GL_SET_OF_BKS_ID. '

    But the following query does not give the expected result.

    Select DECODE (FPOVR. PROFILE_OPTION_VALUE,
    NULL, FPOVS. PROFILE_OPTION_VALUE, FPOVR. ZZ PROFILE_OPTION_VALUE)
    OPS FND_PROFILE_OPTIONS, FND_PROFILE_OPTION_VALUES FPOVR,.
    FND_PROFILE_OPTION_VALUES FPOVS where 1 = 1 and FPOVS. LEVEL_ID (+) = 10001
    and FPOVS. LEVEL_VALUE (+) = 0
    and FPOVS. PROFILE_OPTION_ID (+) IS FRENCH POLYNESIA. PROFILE_OPTION_ID
    and FPOVR. (+) LEVEL_ID = 10003 and FPOVR. LEVEL_VALUE = 21533
    and FPOVR. PROFILE_OPTION_ID (+) IS FRENCH POLYNESIA. PROFILE_OPTION_ID
    and fpo.profile_option_name = 'GL_SET_OF_BKS_ID. '

    Difference between them is a join with external FPOVR. LEVEL_VALUE and hard coded value.

    In fact, the difference is that the condition relating to FPOVR. LEVEL_VALUE to 21533 is part of the outer join condition in the first query, but it is not in the second query.

    Why these query above return different results even if the outer join is made with hard coded in value?

    When you say

    FPOVR.LEVEL_VALUE(+) = 21533
    

    (with a sign +) only the lines of fpovr with level_value = 21533 will join the other table. If there is no such line in fpovr, then a row of output will be generatedd for each row in the other table anyway.
    When you say

    FPOVR.LEVEL_VALUE = 21533
    

    (without a sign +) then the outer join is made using the other conditions, which may result in some lines of the other table who appear in the result set with NULL in places where the values of fpovr would normally appear. Then when the join is complete, the condition is applied, and all these lines with the NULL value instead of fpovr.level_value are deleted because they do not meet the condition "FPOVR. LEVEL_VALUE = 21533 ". The effect is identical to an inner join.

    When you use the old rating of outer join (i.e. with signs +), if any condition involving the fpovr table has a + sign, and then all of the conditions involving table fpovr must have a + sign, otherwise the result will be the same if none of the conditions were a sign +.

  • What is the Assembly of 4 or 5 tables FULL OUTER JOIN logic?

    the query is as below:

    as you can see, I need FULL OUTER JOIN, these 5 tables and get a column from each table that is based on three common columns (ORG_iD, CUST_ID, CURRENT_DT).

    And I wonder what is the logic of the 5 FULL OUTER JOIN table?
    It will return if there is a folder that exists in the single table COL1? or table, COL2 and COL3 and so on. Basically any combination of these 5 tables.

        SELECT (CASE WHEN COL1.ORG_ID IS NOT NULL THEN COL1.ORG_ID
                     WHEN COL2.ORG_ID IS NOT NULL THEN COL2.ORG_ID
                     WHEN COL3.ORG_ID IS NOT NULL THEN COL3.ORG_ID
                     WHEN COL4.ORG_ID IS NOT NULL THEN COL4.ORG_ID
                     ELSE COL5.ORG_ID 
                END) ORG_ID,
                (CASE WHEN COL1.CUST_ID IS NOT NULL THEN COL1.CUST_ID
                     WHEN COL2.CUST_ID IS NOT NULL THEN COL2.CUST_ID
                     WHEN COL3.CUST_ID IS NOT NULL THEN COL3.CUST_ID
                     WHEN COL4.CUST_ID IS NOT NULL THEN COL4.CUST_ID
                     ELSE COL5.CUST_ID
                END) CUST_ID, 
                (CASE WHEN COL1.CURRENT_DT IS NOT NULL THEN COL1.CURRENT_DT
                     WHEN COL2.CURRENT_DT IS NOT NULL THEN COL2.CURRENT_DT
                     WHEN COL3.CURRENT_DT IS NOT NULL THEN COL3.CURRENT_DT
                     WHEN COL4.CURRENT_DT IS NOT NULL THEN COL4.CURRENT_DT
                     ELSE COL5.CURRENT_DT 
                END) CURRENT_DT, 
              'VENDORS' as ITEM_NAME,
              V_AGE_IND as ACCT_AGE_IND,  
              COL1.AMT_ZSHT,  
              COL2.AMT_YFYS,  
              COL3.AMT_YFYS, 
              COL4.AMT_YFYS,  
              COL5.AMT_BZL,  
              'NAV',
              sysdate
        FROM COL1  
                  FULL OUTER JOIN COL2 ON (COL1.ORG_ID=COL2.ORG_ID AND COL1.CURRENT_DT=COL2.CURRENT_DT AND COL1.CUST_ID=COL2.CUST_ID)  
                  FULL OUTER JOIN COL3 ON (COL2.ORG_ID=COL3.ORG_ID AND COL2.CURRENT_DT=COL3.CURRENT_DT AND COL2.CUST_ID=COL3.CUST_ID)  
                  FULL OUTER JOIN COL4 ON (COL3.ORG_ID=COL4.ORG_ID AND COL3.CURRENT_DT=COL4.CURRENT_DT AND COL3.CUST_ID=COL4.CUST_ID)  
                  FULL OUTER JOIN COL5 ON (COL4.ORG_ID=COL5.ORG_ID AND COL4.CURRENT_DT=COL5.CURRENT_DT AND COL4.CUST_ID=COL5.CUST_ID)  
    Any ideas?

    Thank you

    Hello

    When you perform a JOIN EXTERNAL COMPLETE multi - build that way, whenever you add a new table, you can just join the previous table because this table could be all NULL values for a given row. You can reach each new table to the first table, either, for the same reason. You must enclose each new table with all previous tables, like this:

    FULL OUTER JOIN COL2 ON  COL2.ORG_ID     =           COL1.ORG_ID
                   AND COL2.CURRENT_DT =           COL1.CURRENT_DT
                   AND COL2.CUST_ID    =           COL1.CUST_ID
    FULL OUTER JOIN COL3 ON  COL3.ORG_ID     = COLAESCE (COL1.ORG_ID,     COL2.ORG_ID)
                   AND COL3.CURRENT_DT = COALESCE (COL1.CURRENT_DT, COL2.CURRENT_DT)
                   AND COL3.CUST_ID    = COALESCE (COL1.CUST_ID,    COL2.CUST_ID)
    FULL OUTER JOIN COL3 ON  COL4.ORG_ID     = COLAESCE (COL1.ORG_ID,     COL2.ORG_ID,     COL3.ORG_ID)
                   AND COL4.CURRENT_DT = COALESCE (COL1.CURRENT_DT, COL2.CURRENT_DT, COL3.CURRENT_DT)
                   AND COL4.CUST_ID    = COALESCE (COL1.CUST_ID,    COL2.CUST_ID,    COL3.CUST_ID)
    FULL OUTER JOIN COL3 ON  COL5.ORG_ID     = COLAESCE (COL1.ORG_ID,     COL2.ORG_ID,     COL3.ORG_ID,     COL4.ORG_ID)
                   AND COL5.CURRENT_DT = COALESCE (COL1.CURRENT_DT, COL2.CURRENT_DT, COL3.CURRENT_DT, COL4.CURRENT_DT)
                   AND COL5.CUST_ID    = COALESCE (COL1.CUST_ID,    COL2.CUST_ID,    COL3.CUST_ID,    COL4.CUST_ID)  
    

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements), and the results you want from this data.
    Explain how you get these results from these data.
    Always tell what version of Oracle you are using.

  • using (+) or left outer join

    Dear Expert;

    I've been playing by using the two symbol... and realized that they do the same thing... Is it true...? or am I wrong.

    Thank you.

    Hello

    user13328581 wrote:
    Dear Expert;

    I've been playing by using the two symbol... and realized that they do the same thing... Is it true...? or am I wrong.

    They all have two outer joins. The + rating was the original way to do it in Oracle. LEFT, RIGHT, and FULL OUTER JOIN introduced in Oracle 9, but the old way is still supported.

    There are some situations (such as an outer join complete and outer-join a table to two different tables) that are better with the ANSI syntax (it's LEFT OUTER JOIN). It is possible to get the same results using +, but it must be combersome and/or inefficient workarounds. I suggest that you use always LEFT OUTER JOIN (or FULL OUTER JOIN, or, on occasions RIGHT OUTER JOIN). I think that you will find it easier and less error-prone.

  • Functions of outer join left as simple join

    I created two views SCO_REQGROSSLINES_V and SCO_REQLINESCOMPLETE on Oracle applications tables base. Our company applies the following identity rules: the gross number of rows is always greater than or equal number of demand lines. (Full, I mean delivered.)

    Each view has a key named DATESUBINV_KEY built a date of the operation and the code subinventory using this logic:

    TO_CHAR (TRUNC (transaction_date), 'YYYYMMDD') | subinventory_code

    On 03-SEP-2010 a user has created a demand with a line item for the material of the HEAT subinventory who did not. This row is returned in the result set when I ask about SCO_REQGROSSLINES_V but does NOT return when I ask about SCO_REQLINESCOMPLETE. So far so good.

    When I run either of the left outer joins following, I don't get the line for the line for HEAT subinventory 03-SEP-2010:

    Select rgl.trxn_date
    rgl.subinventory
    rgl.line_count gross_line_count
    rgl.ext_prc gross_value
    rlc.line_count lines_filled
    rlc.ext_prc lines_filled_value
    of SCO_REQGROSSLINES_V vö outer join left sco_reqlinescomplete_v rlc
    ON rgl.datesubinv_key = rlc.datesubinv_key
    where vo. TRXN_DATE BETWEEN to_date('29-AUG-2010') AND to_date('04-SEP-2010')
    and rlc.trxn_date BETWEEN to_date('29-AUG-2010') AND to_date('04-SEP-2010')
    order of rgl.trxn_date, rgl.subinventory

    Select rgl.trxn_date, rgl.subinventory
    rgl.line_count gross_line_count
    rgl.ext_prc gross_value
    rlc.line_count lines_filled
    rlc.ext_prc lines_filled_value
    of SCO_REQGROSSLINES_V vo
    sco_reqlinescomplete_v rlc
    where vo. TRXN_DATE BETWEEN to_date('29-AUG-2010') AND to_date('04-SEP-2010')
    and rlc.trxn_date BETWEEN to_date('29-AUG-2010') AND to_date('04-SEP-2010')
    AND rgl.datesubinv_key = rlc.datesubinv_key (+)
    order of rgl.trxn_date, rgl.subinventory

    Question: Why the left outer joins is would work as a simple join on DATESUBINV_KEY? Do the keys function differently from the keys defined in the data dictionary views? If they do how these keys work as data dictionary keys?

    Hello

    The WHERE clause is applied after the outer join is complete. In your example, Vo will be in the game even if they have no match in rlc. In this case, all columns of rlc will be NULL.
    Okay, so you have these lines containing data from vo but NULL values, where the rlc data was supposed to go. Now it's time to start the WHERE clause. You then apply that conditions in the WHERE clause:

    AND     rlc.trxn_date BETWEEN ...
    

    NULL is between what whether, if the line the prodeuced the outer join is rejected.

    All the columns in involivn conditions of rlc probably needs to be part of the join condition, not the WHERE clause.
    For example, in you first ask the FROM and WHERE clauses can be:

    FROM          sco_reqgrosslines_v      rgl
    LEFT OUTER JOIN  sco_reqlinescomplete_v  rlc  ON    rgl.datesubinv_key   = rlc.datesubinv_key
                                            AND   rlc.trxn_date       BETWEEN TO_DATE ( '29-AUG-2010'
                                                                        , 'DD-MON-YYYY'
                                                            )
                                                  AND       TO_DATE ( '04-SEP-2010'
                                                              , 'DD-MON-YYYY'
                                                            )
    WHERE   rgl.trxn_date     BETWEEN TO_DATE ( '29-AUG-2010'
                             , 'DD-MON-YYYY'
                             )
                   AND     TO_DATE ( '04-SEP-2010'
                             , 'DD-MON-YYYY'
                             )
    

    Always use (at least) two arguments when calling TO_DATE.

    Conditions that involve only VO can be in the WHERE clause, but if all the rlc conditions in the WHERE clause, then the effect will be the same as a join internally.

    It is no difference between tables and views (or subqueries) in this regard: the same thing would happen, whether it is vo and rlc really tables or not.

  • Help with sql FULL OUTER JOIN

    Hi all
    I need assistance with SQL FULL OUTER JOIN.

    How to write with FULL OUTER JOIN, the query.
    I tried like


    I have 3 different queries.

    Query q: SELECT emp_id LN.emp_id.
    Sum (LN_amount) loan_amt
    MY_LON_TAB LN
    WHERE LN_amount > 20000
    LN.emp_id GROUP;



    Query b: SELECT PLN. EMP_ID emp_id,
    Sum (PLAN_AMOUNT) plan_amt
    FROM PLN MY_PLAN_TAB
    where PLAN_AMOUNT <>0
    GROUP BY PLN. EMP_ID;


    Query C:

    SELECT FLX. EMP_ID emp_id,
    SUM (PRORATE_AMOUNT) PRORATE_AMT
    OF MY_FLX_TAB FLX
    WHERE PRORATE_AMOUNT <>0
    FLX GROUP. EMP_ID;


    Suppose that the different subquery above 3 a, b, c respectively. each subquery with emp_id and respective amount.

    like a.emp_id, a.loan_amt
    b.emp_id, b.plan_amt
    c.emp_id, c.prorate_amt

    I show all the empid with their amount respective.
    schenario: If an account made, but not vice-versa b
    and B have record, but not vice versa c
    and a credit record but not vice versa c

    first: I have external is associated with the A and B
    Second: join external then complete the total outcome of (a & b) with c
    but empid c just as empty.


    My output is:

    emp_id a.loan_amt, b.plan_amt c.prorate_amt
    101 5000 null null
    102 4500 null 2000
    103 6700 null null


    How to solve the foregoing to the ANSI (FULL OUTER JOIN) method.
    Please suggest me.

    Thanks in advance...
    PKM

    Hello

    It is very difficult for anyone to say what you're doing wrong if they do not know what you are doing. Post your code FULL OUTER JOIN.
    My best guess is:

    WITH     a     AS
    (
         SELECT     ...      -- What you posted as query a
    )
    ,     b     AS
    (
         SELECT     ...      -- What you posted as query b
    )
    ,     c     AS
    (
         SELECT     ...      -- What you posted as query c
    )
    SELECT     COALESCE ( a.emp_id
               , b.emp_id
               , c.emp_id
               )     AS emp_id
    ,     ...     -- whatever other columns you want
    FROM          a
    FULL OUTER JOIN     b  ON     b.emp_id =            a.emp_id
    FULL OUTER JOIN     c  ON     c.emp_id = COALESCE (a.emp_id, b.emp_id)
    ;
    

    I hope that answers your question.
    If not, post a small example (CREATE TABLE and INSERT statements) data for all tables and the results expected from these data (if not what you have already posted).

Maybe you are looking for

  • Podcast XML Feed does not update

    Hello Since May 2009, I have the following podcast that ran (albeit with a 2 year hiatus): https://iTunes.Apple.com/GB/podcast/the-itsawinner-Poker-podcast/id344260020?MT= 2 The XML of talkshoe is: http://recordings.talkshoe.com/rss72195.xml After ou

  • Gigabeat room 2.0.2 only to THE will not install on any computer I try

    I try to install my toshiba gigabeat F40 software (gigabeat room 2.0.2AU) on my new laptop but every time I try to install it, it fails and comes up with the notification: LoadLibrary error (the specified module could not be found) Why is this? Is th

  • Go to iOS app

    Right, recently got myself an iPhone. Has been very good to me until I realized that switching to android to iPhone 5 s was not as easy as I thought it would be. Started using the iPhone and accustomed to him, began to add photos and regular phone or

  • I can't see the pictures in my computer

    Hello.. I want to see the pictures in my computer, but I can't until I click on it... I have an appointment in pictures then open a file but then I see the icons only... I can see the pictures when I click it

  • How to convert a video format

    Taking videos How can you change a format that says that Windows Vista Movie Maker may not import into a format it will except. Is this possible?