Outer joins are equijoins and?

Manual says Yes, but I think their only equijoins, insofar as the matched data and include other data as well. so technically should not fall outside the category of the equijoins?

Hello

Outer joins can be are equijoins.  In other words, some outer joins are of equijoins, others are not.

Tags: Database

Similar Questions

  • outer join on the aggregate query

    This is probably a relatively simple matter, as long as I explain it well enough:

    I have two tables:

    categorycodes and properties

    categorycodes is a lookup table.

    both tables have a catcode field which is a char (1) that contains matching data (only the numbers 1 to 6)

    CREATE

    TABLE CATEGORYCODES

    (

    CATCODE CHAR (1 BYTE) NOT NULL,

    DESCRIPTION VARCHAR2 (25 BYTE) NOT NULL,

    CONSTRAINT CATEGORYCODES_PK PRIMARY KEY (CATCODE) ALLOW

    )

    catCode

    1

    2

    3

    4

    5

    6

    The properties table has approximately 600 000 records. The properties table also has a field named parcelno which is a tank (9).  It contains a string of figures and numbers only.

    What I would like is:

    catCode, count (*)

    1 580

    2 300

    3 3000

    4 235

    5 0

    6 80

    I limited the results of the query to make sure it was a game that would not all catcodes in it.  I have trouble to get the one with zero to display.  I know that this has to do with how I do the join, but I don't know what.

    It is a sample of what I've tried:

    Select i.

    Of

    (select catcode, count (*)

    property p

    where substr (parcelno, 1, 3) = ' 871 "

    Catcode group) i

    outer join right categorycodes cc

    We i.catcode = cc.catcode;

    I'm not worried about the situations where catcode is null in the properties.  Parcelno cannot be null.

    Hello

    Looks like your query should work; except that you won't COUNT (*); That would make each issue at least 1.  COUNT (*) means that count the total number of lines, no matter what is on them, so he'll see the line with just the catcode of the lookup table that matches nothing and which count as 1.  You want to count the number of rows in the table of properties, so expect a column of the properties that cannot be NULL.

    Here is a slightly different way

    SELECT c.catcode

    EARL of (p.catcode) AS cnt

    OF categorycodes c

    P ON p.catcode = c.catcode LEFT OUTER JOIN properties

    AND SUBSTR (p.parcelno

    1

    3

    ) = ' 871 "

    ;

    If the condition about 871' ' part of the join condition, then you don't need a subquery.

    .

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    Point where the above statement is erroneous results, and explain, using specific examples, how you get the right result of data provided in these places.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

  • Partition outer join

    Hello

    I want a report that shows data for all combinations of dimensions, although in fact no data exists for them.

    http://download.Oracle.com/docs/CD/E11882_01/server.112/e10578/tdpdw_sql.htm#TDPDW0072
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    Here's my data model, inventory with a status as 'sold out' or 'available' and the designer of the element
    DROP TABLE inventory
    /
    DROP TABLE inv_status
    /
    DROP TABLE designer
    /
    CREATE TABLE inv_status(
         id          NUMBER  PRIMARY KEY
        ,description VARCHAR2(12)
        )
    /
    CREATE TABLE designer(
         id          NUMBER  PRIMARY KEY
        ,name        VARCHAR2(12)
        )
    /
    CREATE TABLE inventory(
         id          NUMBER  PRIMARY KEY
        ,fk_ist      NUMBER
            CONSTRAINT fk_inv_status
            REFERENCES inv_status (id)
        ,fk_des      NUMBER
            CONSTRAINT fk_designer
            REFERENCES designer (id)
        ,name        VARCHAR2(20)
        ,description VARCHAR2(12)
        )
    /
    and some examples of data
    INSERT INTO inv_status (id,description) VALUES (25,'sold out');
    INSERT INTO inv_status (id,description) VALUES (26,'available');
    INSERT INTO inv_status (id,description) VALUES (27,'comming soon');
    INSERT INTO inv_status (id,description) VALUES (28,'not in use');
    
    INSERT INTO designer (id,name) VALUES (111,'Marco');
    INSERT INTO designer (id,name) VALUES (112,'Tommy');
    INSERT INTO designer (id,name) VALUES (113,'Daisy');
    INSERT INTO designer (id,name) VALUES (114,'Laura');
    
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (1,25,112,'moon boot','k');
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (2,25,113,'high heel','r');
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (3,26,114,'sandal','f');
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (4,26,113,'flip-flop','u');
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (5,27,112,'horseshoe','j');
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (6,27,114,'magic pair of boots','o');
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (7,27,113,'runner','r');
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (8,27,112,'loafer',NULL);
    INSERT INTO inventory (id,fk_ist,fk_des,name,description) VALUES (9,27,113,'climbing spur',NULL);
    COMMIT;
    I need a simple outer join to find each status as well as the objects (if available)
    SELECT  ist.id ist
           ,inv.id
           ,inv.name
           ,ist.description
    FROM    inv_status ist
            LEFT JOIN inventory inv
              ON (ist.id = inv.fk_ist)
    ORDER BY ist.id, inv.id;
    /*
    IST ID  NAME                 DESCRIPTION
    --- --- -------------------- ------------
    25  1   moon boot            sold out
    25  2   high heel            sold out
    26  3   sandal               available
    26  4   flip-flop            available
    27  5   horseshoe            comming soon
    27  6   magic pair of boots  comming soon
    27  7   runner               comming soon
    27  8   loafer               comming soon
    27  9   climbing spur        comming soon
    28                           not in use
    
    10 rows selected
    */
    The same I get with a left join partition
    SELECT  ist.id ist
           ,inv.id
           ,inv.name
           ,ist.description
    FROM    inv_status ist
            PARTITION BY (ist.id)
            LEFT JOIN inventory inv
              ON (ist.id = inv.fk_ist)
    ORDER BY ist.id, inv.id;
    /*
    IST ID  NAME                 DESCRIPTION
    --- --- -------------------- ------------
    25  1   moon boot            sold out
    25  2   high heel            sold out
    26  3   sandal               available
    26  4   flip-flop            available
    27  5   horseshoe            comming soon
    27  6   magic pair of boots  comming soon
    27  7   runner               comming soon
    27  8   loafer               comming soon
    27  9   climbing spur        comming soon
    28                           not in use
    
    10 rows selected
    */
    But what is the right partition join? Why do I have multiple lines for each State where no items exist? Or in other words: someone can tell me what I asked of the DB and it makes sense to ask him: -?
    SELECT  ist.id ist
           ,inv.id
           ,inv.name
           ,ist.description
    FROM    inventory inv
            PARTITION BY (inv.fk_ist)
            RIGHT JOIN inv_status ist
              ON (ist.id = inv.fk_ist)
    ORDER BY ist.id, inv.id;
    /*
    IST ID  NAME                 DESCRIPTION
    --- --- -------------------- ------------
    25  1   moon boot            sold out
    25  2   high heel            sold out
    25                           sold out
    25                           sold out
    26  3   sandal               available
    26  4   flip-flop            available
    26                           available
    26                           available
    27  5   horseshoe            comming soon
    27  6   magic pair of boots  comming soon
    27  7   runner               comming soon
    27  8   loafer               comming soon
    27  9   climbing spur        comming soon
    27                           comming soon
    27                           comming soon
    28                           not in use
    28                           not in use
    28                           not in use
    
    18 rows selected
    */
    For any combination of x as well as objects Designer item (if available) again a simple Cartesian product is easy to do.
    SELECT  ist.id ist
           ,des.id des
           ,inv.id
           ,inv.name
           ,ist.description
           ,des.name designer
    FROM    inv_status ist
            CROSS JOIN designer des
            LEFT JOIN inventory inv
              ON (ist.id = inv.fk_ist
                 AND des.id = inv.fk_des
                 )
    ORDER BY ist.id,des.id,inv.id;
    /*
    IST DES ID  NAME                 DESCRIPTION  DESIGNER
    --- --- --- -------------------- ------------ ------------
    25  111                          sold out     Marco
    25  112 1   moon boot            sold out     Tommy
    25  113 2   high heel            sold out     Daisy
    25  114                          sold out     Laura
    26  111                          available    Marco
    26  112                          available    Tommy
    26  113 4   flip-flop            available    Daisy
    26  114 3   sandal               available    Laura
    27  111                          comming soon Marco
    27  112 5   horseshoe            comming soon Tommy
    27  112 8   loafer               comming soon Tommy
    27  113 7   runner               comming soon Daisy
    27  113 9   climbing spur        comming soon Daisy
    27  114 6   magic pair of boots  comming soon Laura
    28  111                          not in use   Marco
    28  112                          not in use   Tommy
    28  113                          not in use   Daisy
    28  114                          not in use   Laura
    
    18 rows selected
    */
    But I just can't get with the join of LEFT or RIGHT partition
    SELECT  inv_ist.ist
           ,des.id des
           ,inv_ist.id
           ,inv_ist.name
           ,inv_ist.description
           ,des.name designer
    FROM    designer des
            PARTITION BY (des.id)
            LEFT JOIN (
                SELECT  ist.id ist
                       ,inv.fk_des
                       ,inv.id
                       ,inv.name
                       ,ist.description
                FROM    inv_status ist
                        PARTITION BY (ist.id)
                        LEFT JOIN inventory inv
                          ON (ist.id = inv.fk_ist)
                ) inv_ist
            ON (des.id = inv_ist.fk_des
               OR inv_ist.fk_des IS NULL)
    ORDER BY inv_ist.ist,des.id,inv_ist.id;
    /*
    IST DES ID  NAME                 DESCRIPTION  DESIGNER
    --- --- --- -------------------- ------------ ------------
    25  112 1   moon boot            sold out     Tommy
    25  113 2   high heel            sold out     Daisy
    26  113 4   flip-flop            available    Daisy
    26  114 3   sandal               available    Laura
    27  112 5   horseshoe            comming soon Tommy
    27  112 8   loafer               comming soon Tommy
    27  113 7   runner               comming soon Daisy
    27  113 9   climbing spur        comming soon Daisy
    27  114 6   magic pair of boots  comming soon Laura
    28  111                          not in use   Marco
    28  112                          not in use   Tommy
    28  113                          not in use   Daisy
    28  114                          not in use   Laura
    
    13 rows selected
    */
    SELECT  inv_ist.ist
           ,des.id des
           ,inv_ist.id
           ,inv_ist.name
           ,inv_ist.description
           ,des.name designer
    FROM    (
            SELECT  ist.id ist
                   ,inv.fk_des
                   ,inv.id
                   ,inv.name
                   ,ist.description
            FROM    inventory inv
                    PARTITION BY (inv.fk_ist)
                    RIGHT JOIN inv_status ist
                      ON (ist.id = inv.fk_ist)
            ) inv_ist
            PARTITION BY (inv_ist.fk_des)
            RIGHT JOIN designer des
              ON (des.id = inv_ist.fk_des)
    ORDER BY inv_ist.ist,des.id,inv_ist.id;
    /*
    IST DES ID  NAME                 DESCRIPTION  DESIGNER
    --- --- --- -------------------- ------------ ------------
    25  112 1   moon boot            sold out     Tommy
    25  113 2   high heel            sold out     Daisy
    26  113 4   flip-flop            available    Daisy
    26  114 3   sandal               available    Laura
    27  112 5   horseshoe            comming soon Tommy
    27  112 8   loafer               comming soon Tommy
    27  113 7   runner               comming soon Daisy
    27  113 9   climbing spur        comming soon Daisy
    27  114 6   magic pair of boots  comming soon Laura
        111                                       Marco
        111                                       Marco
        111                                       Marco
        111                                       Marco
        112                                       Tommy
        112                                       Tommy
        112                                       Tommy
        113                                       Daisy
        113                                       Daisy
        113                                       Daisy
        114                                       Laura
        114                                       Laura
        114                                       Laura
    
    22 rows selected
    */
    Does anyone know a simple description, something like 'Partition of outer join for Dummies

    Concerning
    Marcus

    Edited by: Marwim the 28.12.2010 09:11
    Typo

    Hey, Marcus,

    Marwim wrote:
    And that's exactly my problem: what kind of problems can I solve with outer joins partitioned?

    Programming would be much easier (and therefore less interesting and less well-paid) if it has nice, short answers to these questions.

    According to my experience, cross joins are the best when you dimension tables and partitioned outer joins are good when you don't.
    Cionsider the following partitioned outer join, which shows all the possible combinations of the job and the Department:

    SELECT       d.dname
    ,       e.deptno
    ,       e.job
    ,       e.ename
    FROM          scott.dept     d
    LEFT OUTER JOIN     scott.emp     e     PARTITION BY (e.job)
              ON     d.deptno     = e.deptno
    ORDER BY  d.deptno
    ,       e.job
    ;
    

    Output:

    DNAME              DEPTNO JOB       ENAME
    -------------- ---------- --------- ---------
    ACCOUNTING                ANALYST
    ACCOUNTING             10 CLERK     MILLER
    ACCOUNTING             10 MANAGER   CLARK
    ACCOUNTING             10 PRESIDENT KING
    ACCOUNTING                SALESMAN
    ...
    OPERATIONS                ANALYST
    OPERATIONS                CLERK
    OPERATIONS                MANAGER
    OPERATIONS                PRESIDENT
    OPERATIONS                SALESMAN
    

    It's a great use of a partitioned outer join, because there is no dimension table for employment (that is, there is no table with one line per job, which may be the target of a key foregin reference). You can use a join Cross (more an external koin) to get the same results, but it would be a subquery such as

    WITH  all_jobs  AS
    (
        SELECT DISTINCT  job
        FROM           scott.emp
    ) ...
    

    to create a table dimesnion to the fly.

    There may be exceptions. For example, if you don't have a table, but there are some jobs that actually occur in the emp table, and you want the output to include only the jobs that exist in the emp table, then the easiest thing is just to ignore the jobs table and do the partitioned outer join illustrated above.

  • OBIEE - outer joins

    Hello

    I have create a join foreign key between the table dimension and in the physical layer. Is it possible to create an outer join on the columns, the option (driving and type) in properties is gray and is by default 'indoor '. How you can activate this option?

    Thank you

    Hello

    You create outer joins in the business layer, but the OBIEE outer joins are not like SQL outer join. They can lead to strange errors.

    Its better to do these things in ETL.

    Thank you
    Sandeep

  • Show all dates between date range (time Dimension is left outer join)

    All,

    I did some research on this issue, but in all positions on date variables, date prompts and date filtering I have not seen one exactly to my question (perhaps that they are and I don't have my head around it properly yet).

    My requirement of report is to allow a user to select a start date and an end of day. The report is expected to show the activity of these two days - AND display 0/null on days where there is no activity. This second part is where I am getting hung up.

    The paintings in question are:
    Timedim
    EventFact
    CustomerDim

    My MDB is configured as follows:
    Left outer join of Timedim EventFact
    Inner join CustomerDim EventFact

    If I run a report by selecting the DAYS of Timedim and an EventFact measure1 with range day 01/01/2010-31/12/2010... A record for each day and it looks perfect because of the left outer join between Timedim and CustomerDim.

    But... If I add a CustomerDim field, Select TimeDim.DAY, CustomerDim.CUSTNAME, EventFact.MEASURE1, OBIEE returns only records for the days that have record EventFact.

    This is due to the fact that the Timedim is always external joined in EventFact, but adding in fact CustomerDim OBIEE set up an inner join between tables that will only return data where there are data EventFact.

    There is a way around it in this simple case, and that is to define the relationship between CustomerDim and EventFact as an outer join as well. This will give the desired effect (but an outer join between the two tables is not the real relationship) and I have add an extra dimension and add additional sources of logic to a single dimension in MDB it becomes complicated and messy.

    Also, ive ruined with the definition of the conduct in the relationship table, etc... but he gave not the desired effect.

    Has anyone ever met the need for force display all dates within a range specified with a fact table that does not have an entry for each date?

    Thanks in advance.

    K

    Published by: user_K on April 27, 2010 11:32

    Hi there, the easiest way is to the LTS himself. Double-click your LTS, go to the tab with the column mappings. Make sure you have checked "show no mapped" column.

    You should see your new dummy column in the list, in the central part of mapping (IE not the right) just enter 0, or launch the expression editor and enter 0 in there.
    simple!

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

    I can't understand how to combine a full outer join with a different type of join... is it possible?

    Here are some create table and insert for examples of database:
    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 that 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     4
    I tried a number of different things, google 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, it's a full outer join of t1 and t2 on workstation and a cross join of one with the t3. I wonder if I can't find examples of it online because it is not possible...

    Note: I'm stuck dealing with Oracle 8i

    Thank you!!

    Hello

    The query I posted yesterday is a little more complex that it should be.
    My_tab2.workstation is unique, there is no reason to make a separate subquery as mt1. We can join my_tab1 to my_tab2 and get the SUM in a subquery.

    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, and very clear expected results!

    user11033437 wrote:
    ... So, what I want, it's a full outer join of t1 and t2 on workstation and a cross join of one with the t3.

    She, exactly!
    The trickiest part is when and how get SUM (my_value). You could address the question of exactly what my_tab3 must be attached to a cross that's exactly what should look like the result set of the full outer join between my_tab1 and my_tab2 to. To do this, take your desired results, remove columns that do not come from the outer join complete and delete duplicate rows. You will get:

    workstation     sum(my_value)     wkstn_name
    -----------     -------------   ----------
    ABCD          30          WKSTN 1
    A123          35          WKSTN 2
    B456          0          WKSTN 3
    ????          5          NULL          
    

    So the heart of the problem is how to get these results of my_tab1 and my_tab2, which is done in the subquery FOJ above.

    I tried to use auto-documenté in my code names. I hope you can understand.
    I could spend hours explaining the different parts of this query more in detail, but I don't know that I would lose some of that time, explain things that you already understand. If you want an explanation of the specific element (s), let me know.

  • Outer join does not

    Hello

    Pls help me my request. I tried the following, but it does not give the expected results.

    Tab1
    EmplId, RepDt, Code, Hrs
    1/100,1/2009,199,8
    1/100,1/2009,200,4
    1/100,1/2009,255,3
    200,1/1/2009,200,4
    100.5/1/2009,199,8


    Tab2
    EmplId, RepDt, Code, Hrs
    1/100,1/2009,200,6
    200,1/1/2009,200,3

    I need output like this - 4 rows - need of all the rows from TAB1 when EMPLID, REPDT match TAB2, field values: need at a time when Code is also, when emlid, correspondence of the date, the Code missing so need A hrs, display ZERO as Tab2 hours.

    1/100,1/2009,199,8,0 - did not exist is not in tab2, so hrs Tab2 is ZERO
    1/100,1/2009,200,4,6 - Emplid, RepDt, Code match existence in Tab2, Tab1 Hrs 8, 6 Hrs Tab2
    1/100,1/2009,255,3,0 - did not exist is not in Tab2, so Tab2 hrs is equal to ZERO
    200,1/1/2009,200,4,3 - Emplid, Repdt, Code Match existed in Tab2, 4 Hrs of Tab1, Tab2 3 Hrs

    We are in 10g, Oracle.

    I tried the following
    T1. EmplId = T2.emplid AND T1.repdt = T2.repdt AND T1.code, T2.code = (+) - returns the unique corresponding lines, 2 rows.

    Pls help.

    Thanks in advance.

    Published by: NL 23 February 2009 09:20

    Hello

    See the Boneist first message in this thread:

    select t1.emplid, t1.repdt, t1.code, t1.hrs, nvl(t2.hrs, 0)
    from   tab1 t1,
           tab2 t2
    where  t1.emplid = t2.emplid (+)
    and    t1.repdt = t2.repdt (+)
    and    t1.code = t2.code (+)
    and    (t1.emplid, t1.repdt) in (select emplid, repdt
                                     from   tab2)
    order by repdt, emplid, code;
    

    As Boneist said, this fact corresponds to option (b)
    "(b) do just an outer join, with a condition EXISTS (or IN) in the WHERE clause to find corresponding repdts.
    The

    (+)
    

    an outer join are signs.

  • Outer join or a function of the level line

    Hi all

    I have a question which involves five tables T1, R1, R2, R3, and R4. T1 is an operating table, while R1, R2, R3, and R4 are tables of references (tables parent, with the foreign keys defined in T1). Table T1 contains always referenced data R2 and R1. BUT table T1 can sometimes contain NULL for R3 and R4.

    Now my question is simple;
    Should I use an OUTER Join for R3 and R4 in the query? as

    < code >
    Select T1.col1, R1.col2, R2.col2, R3.col2, R4.col2
    T1, R1, R2, R3, R4
    where T1.col2 = R1.col1
    and T1.col3 = R2.col1
    and T1.col4 = R3.col1 (+)
    and T1.col5 = R4.col1 (+)
    < code >

    OR

    Can I use level functions online for R3 and R4, as

    < code >
    Select T1.col1, R1.col2, R2.col2,
    (Select R3.col2 in R3 where R3.col1 = T1.col4),
    (Select R4.col2 in R4 where R4.col1 = T1.col5)
    T1, R1, R2
    where T1.col2 = R1.col1
    and T1.col3 = R2.col1
    < code >

    Which approach is better and why?

    Records in T1 = 2 000 000
    R1 = 1000 records
    Records in R2 = 300
    Records in R3 = 1800
    Records in R4 = 200

    Please note that all foreign keys are indexed, there are primary keys for all the tables in R

    Thank you
    QQ.

    According to the 'official' documentation the outer join should be the by far best choice, because I still think the Oracle documentation says that the subquery will be executed for each row of the main query.

    But the Oracle execution engine is a lot smarter (I think from Oracle 8i) and offers a "Value for the filter" feature supposedly which also applies to the "scalar subqueries" you are talking about to (but only if the subquery is considered to be deterministic, i.e. returns always the same value for the same input value of the main request).

    Basically, this Treaty optimization the subquery as a function of an input value (the link to the main request) and an output value (the result of the query) and maintains a hash table in memory of pairs of input/output value. The size of the changes table in memory from one version to the other, I think in 9i, it is set by default to 256 entries but in 10g, it is limited in size and therefore the number of entries depends on the size of the values to store.

    The effectiveness of this optimization of memory-search in the table depends on certain factors such as the number of pairs of distinct value, the order of the incoming values and collisions in the table which can be occur according to hash values.

    Jonathan Lewis has an in-depth coverage of these mechanism in its "cost-based Oracle: Fundamentals" book.

    To make a long story short, since your tables R3 and R4 are relatively low, you might want to give a chance, because these optimizations could work very well in your particular case, but unfortunately the real result is simply unpredictable due to the above constraints, including the order of the incoming values.

    Kind regards
    Randolf

    Oracle related blog stuff:
    http://Oracle-Randolf.blogspot.com/

    SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676 /.
    http://sourceforge.NET/projects/SQLT-pp/

  • OUTER JOIN query returns the results of JOIN IN-HOUSE 11.2.0.1.0

    I'm data transfer in 11.2.01.0 (Windows XP 32-bit) and I wanted to compare the sizes of table with the same Table name in two different patterns, ML and SILENT, with a FULL OUTER JOIN (to account for all the tables and NULL values in a diagram).

    The scheme of ML has 176 tables: schema TUT a 133 tables. The use of a standard INNER JOIN gives 131 paintings.

    I get precisely the results with a FULL OUTER JOIN I get with an INTERNAL JOIN (not the same NULL values so I know they exist).

    This happens in SQL-Plus, SQL_Developer and using Oracle Wire pilot of Data_Direct.

    Here is the code:

    Login: SYS as SYSDBA or SYSTEM (same results for either)

    SELECT M.TABLE_NAME, M.NUM_ROWS, T.TABLE_NAME, T.NUM_ROWS
    OF SYS. ALL_TABLES M FULL OUTER JOIN SYS. ALL_TABLES T ON M.TABLE_NAME = T.TABLE_NAME
    WHERE
    M.OWNER = 'ML' AND
    T.OWNER = 'TUT';

    Produce the same results with LEFT OUTER joins and RIGHT OUTER joins in ASI and Oracle (+) syntax.

    Any thoughts?

    Hello

    If you read what I posted, forget it. MScallion (below) gave the correct answerr.

    If conditions such as

    owner   = 'ML'
    

    in the WHERE clause, and then they will reject the rows of the result set formed by the join condition.

    The inner join returns only 131 lines where the two 'paintings' have the same table_names.
    The outer joins return multiple lines (133, 176 or 178) before the place WHERE the provision is applied , but the WHERE clause eliminates all lines except the 131 found by the inner join.

    Published by: Frank Kulash, July 10, 2010 14:23

  • outer join when there are several tables are involved

    Could not put up the question correctly to the last channel, my problem is with the join when there are several tables are involved, this is just one example of the task that I have to carry.

    Tab1 aura model id retailer_id information for all the weeks (from the first Monday) of the month of JUNE with cost and Helen

    Tab1

    model_id

    retailer_id

    sell_date

    cost

    Helene

    1

    12

    June 3, 13

    100

    40

    1

    12

    June 10, 13

    200

    20

    1

    12

    17 June 13

    300

    20

    1

    12

    24 June 13

    400

    20

    2

    12

    June 3, 13

    300

    10

    2

    12

    June 10, 13

    200

    20

    2

    12

    17 June 13

    300

    20

    2

    12

    24 June 13

    400

    20

    Tab2:

    each retailer belongs to a dealer, under the table has the same information

    retailer_id

    Dealer_id

    12

    100

    13

    100

    14

    101

    15

    101

    16

    101

    Tab 3

    There is a third layer where each dealership is having a garage band

    Dealer_id

    Dealer_group

    100

    1001

    101

    1001

    102

    2001

    103

    2001

    104

    3001

    105

    3001

    Tab4:

    Of this table for each model and dealer discount information for the month of June (every week)

    model_id

    Dealer_group

    discount_date

    discount

    1

    1001

    June 3, 13

    10

    1

    1001

    June 10, 13

    20

    1

    1001

    17 June 13

    10

    1

    1001

    24 June 13

    30

    2

    1001

    June 3, 13

    10

    2

    1001

    June 10, 13

    20

    2

    1001

    17 June 13

    10

    2

    1001

    24 June 13

    30

    3

    2001

    June 3, 13

    10

    3

    2001

    June 10, 13

    20

    3

    2001

    17 June 13

    10

    3

    2001

    24 June 13

    30

    Master_info:

    It's the main table which is the master table for model /retailer information

    Model_id

    retailer_id

    1

    12

    2

    12

    3

    12

    4

    12

    1

    13

    2

    13

    Output

    model_id

    retailer_id

    sell_date

    cost

    Helene

    Final (cost-helene-discount)

    1

    12

    June 3, 13

    100

    40

    50

    1

    12

    June 10, 13

    200

    20

    160

    1

    12

    17 June 13

    300

    20

    270

    1

    12

    24 June 13

    400

    20

    350

    2

    12

    June 3, 13

    300

    10

    280

    2

    12

    June 10, 13

    200

    20

    160

    2

    12

    17 June 13

    300

    20

    270

    2

    12

    24 June 13

    400

    20

    350

    3

    12

    June 3, 13

    0

    0

    0

    3

    12

    June 10, 13

    0

    0

    0

    3

    12

    17 June 13

    0

    0

    0

    3

    12

    24 June 13

    0

    0

    0

    4

    12

    June 3, 13

    0

    0

    0

    4

    12

    June 10, 13

    0

    0

    0

    4

    12

    17 June 13

    0

    0

    0

    4

    12

    24 June 13

    0

    0

    0

    1

    13

    June 3, 13

    0

    0

    0

    1

    13

    June 10, 13

    0

    0

    0

    1

    13

    17 June 13

    0

    0

    0

    1

    13

    24 June 13

    0

    0

    0

    2

    13

    June 3, 13

    0

    0

    0

    2

    13

    June 10, 13

    0

    0

    0

    2

    13

    17 June 13

    0

    0

    0

    1

    13

    24 June 13

    0

    0

    0

    For highted above records (model_id / retailer_id combination) there is no record in tab1 but they have entered in master_info then the recordings should come for all model_id/retailer_id with all the 0 values

    Hello

    Thanks for posting the sample data.

    It is unclear what dates you want to include in the output.  The following query shows how you can generate every Monday in a given range.  If you only want to include the dates that are actually present in tabl1 and/or tab4, you can simplify this a bit.

    WITH date_range AS

    (

    SELECT TRUNC (TO_DATE (' 3 June 2013', 'DD-Mon-YYYY'))

    , 'IW '.

    ) AS first_monday

    , TRUNC (TO_DATE (24 June 2013 ', 'DD-Mon-YYYY') + 6)

    , 'IW '.

    ) AS last_monday

    OF the double

    )

    all_mondays AS

    (

    First_monday SELECT + (7 * (LEVEL - 1)) AS sell_date

    OF date_range

    CONNECT BY LEVEL<= 1="" +="" (="" (last_monday="" -="">

    / 7

    )

    )

    SELECT mi.model_id

    mi.retailer_id

    am.sell_date

    , Cost of NVL (t1.cost, 0) AS

    , NVL (t1.rebat, 0) IN the refund

    , NVL (t1.cost, 0)

    -(NVL (t1.rebat, 0))

    + NVL (t4.discount, 0)

    ) AS final

    E master_info

    CROSS JOIN all_mondays am

    LEFT OUTER JOIN tab1 t1 ON t1.model_id = mi.model_id

    AND t1.retailer_id = mi.retailer_id

    AND t1.sell_date = am.sell_date

    LEFT OUTER JOIN tab2 t2 ON t2.retailer_id = mi.retailer_id

    LEFT OUTER JOIN tab 3 t3 ON t3.dealer_id = t2.dealer_id

    LEFT OUTER JOIN tab4 t4 ON t4.model_id = t1.model_id

    AND t4.dealer_group = t3.dealer_group

    AND t4.discount_date = t1.sell_date

    ORDER BY mi.retailer_id

    mi.model_id

    am.sell_date

    ;

    The results are not exactly what said you you wanted.  I suspect it's because of typos in that you posted.

  • 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

  • outer join and LignesMax problem left

    I'm having a problem with the method and an sql join. My left table includes some documents that I want in the list, max 25 per page. These records have some notes are related in another table that is outer joined. When I specify the method in my cfoutput tag it includes my external joined table rows. So I could only go 5 records in my table left and 20 of my attachment table. What I want is 25 records in my table on the left and however the number of records in the table on the other that could be associated with these 25 records. Is this possible?

    I make two requests and avoid the outer join in this case:

  • Problem with Outer join and filter

    Hello

    I join two tables in the source using a left outer join. Outside of the join, I have a filter specified with condition TabA.C1 > TabB.C2.

    Now, when ODI generates the query it puts the left outer join on the filter condition as well. So he puts filter as

    where
    (1 = 1)
    And ((TabA.C1 = TabB.C1 (+)) AND)
    (TabA.C2 = TabB.C2 (+))
    And TabA.C10 > TabB.C14 (+)

    How to avoid this problem. I tried this performance on stage as well, always generated query remains the same.

    I use the incremental update of the IKM Oracle. My source and target are both on the same PB.


    ~ Chikk

    Hi Chikk,

    If you analyze the data, you'll see it's OK to have the "(+)" to the filter...

    Anyway, if you want to drop it, leave it as inner join and put the "(+)" manually to the join object.

    This help you?

  • Left outer join query and check the status

    Hello

    I have two tables as tables below

    table_1

    MI_ACC_IDENTIFIERCHARGE_START_DATECHARGE_END_DATEPBA_INT_AMT
    200000000001 SEP-05 00.00.0029 SEP-05 00.00.000.26
    200000000030 SEP-05 00.00.0031 OCTOBER 05 00.00.001.92
    20000000001 NOVEMBER 05 00.00.00NOVEMBER 30 05 00.00.000.34
    20000000001 AUGUST 06 00.00.0031 AUGUST 06 00.00.000.47
    200000000031 MARCH 06 00.00.0027 APRIL 06 00.00.000.34
    200000000030 DECEMBER 05 00.00.0031 JANUARY 06 00.00.001.92
    20000000001 MARCH 05 00.00.0031 MARCH 05 00.00.000.26

    Table_2

    MI_ACC_IDENTIFIERCHARGE_START_DATECHARGE_END_DATETOT_INT_AMT_OVER_25P
    200000000030 SEP-05 00.00.0031 OCTOBER 05 00.00.000
    20000000001 NOVEMBER 05 00.00.00NOVEMBER 30 05 00.00.000.81756
    20000000001 DECEMBER 05 00.00.0029 DECEMBER 05 00.00.000.64724
    200000000030 DECEMBER 05 00.00.0031 JANUARY 06 00.00.005.51555

    Power required:

    MI_ACC_IDENTIFIERCHARGE_START_DATECHARGE_END_DATENVL(B.PBA_INT_AMT,0)TOT_INT_AMT_OVER_25P
    20000000001 NOVEMBER 05 00.00.00NOVEMBER 30 05 00.00.000.340.81756
    200000000030 DECEMBER 05 00.00.0031 JANUARY 06 00.00.001.925.51555
    20000000001 DECEMBER 05 00.00.0029 DECEMBER 05 00.00.0000.64724

    I have to check if TOT_INT_AMT_OVER_25P > B.PBA_INT_AMT and also required to display if there is no matching record in table_1 and exist in table_2 then display as well

    Queries for the table:

    CREATE TABLE 'TABLE_1 '.

    (

    ACTIVATE THE "MI_ACC_IDENTIFIER" NUMBER (10,0) NOT NULL,

    DATE OF THE "CHARGE_START_DATE."

    DATE OF THE "CHARGE_END_DATE."

    NUMBER (15.2) "PBA_INT_AMT".

    );

    Insert into TABLE_1 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, PBA_INT_AMT) values (2000000000, to_date ('01 - SEP - 05 00.00.00','DD-MON-RR HH24.MI.)) SS'), to_date (29-SEP-05 00.00.00','DD-MON-RR HH24.MI.) SS'), 0.26);

    Insert into TABLE_1 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, PBA_INT_AMT) values (2000000000, to_date (30-OCT-05 00.00.00','DD-MON-RR HH24.MI.)) SS'), to_date (31 October 05 00.00.00','DD-MON-RR HH24.MI.) SS'), 1.92);

    Insert into TABLE_1 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, PBA_INT_AMT) values (2000000000, to_date (1 November 05 00.00.00','DD-MON-RR HH24.MI.)) To_date SS'), (30 November 05 00.00.00','DD-MON-RR HH24.MI.) SS'), 0.34).

    Insert into TABLE_1 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, PBA_INT_AMT) values (2000000000, to_date (1 August 06 00.00.00','DD-MON-RR HH24.MI.)) SS'), to_date (31 August 06 00.00.00','DD-MON-RR HH24.MI.) SS'), 0.47);

    Insert into TABLE_1 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, PBA_INT_AMT) values (2000000000, to_date (31 March 06 00.00.00','DD-MON-RR HH24.MI.)) To_date SS'), (27 April 06 00.00.00','DD-MON-RR HH24.MI.) SS'), 0.34).

    Insert into TABLE_1 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, PBA_INT_AMT) values (2000000000, to_date (30 December 05 00.00.00','DD-MON-RR HH24.MI.)) To_date SS'), (31 January 06 00.00.00','DD-MON-RR HH24.MI.) SS'), 1.92);

    Insert into TABLE_1 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, PBA_INT_AMT) values (2000000000, to_date (1 March 05 00.00.00','DD-MON-RR HH24.MI.)) SS'), to_date (31 March 05 00.00.00','DD-MON-RR HH24.MI.) SS'), 0.26);

    CREATE TABLE 'TABLE_2.

    (

    ACTIVATE THE "MI_ACC_IDENTIFIER" NUMBER (10,0) NOT NULL,

    DATE OF THE "CHARGE_START_DATE."

    DATE OF THE "CHARGE_END_DATE."

    "TOT_INT_AMT_OVER_25P" NUMBER (15.5)

    );

    Insert in TABLE_2 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, TOT_INT_AMT_OVER_25P) values (2000000000, to_date (30-OCT-05 00.00.00','DD-MON-RR HH24.MI.)) SS'), to_date (31 October 05 00.00.00','DD-MON-RR HH24.MI.) SS'), 0);

    Insert in TABLE_2 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, TOT_INT_AMT_OVER_25P) values (2000000000, to_date (1 November 05 00.00.00','DD-MON-RR HH24.MI.)) To_date SS'), (30 November 05 00.00.00','DD-MON-RR HH24.MI.) SS'), 0.81756);

    Insert in TABLE_2 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, TOT_INT_AMT_OVER_25P) values (2000000000, to_date (1 December 05 00.00.00','DD-MON-RR HH24.MI.)) SS'), to_date (29 December 05 00.00.00','DD-MON-RR HH24.MI.) SS'), 0.64724);

    Insert in TABLE_2 (MI_ACC_IDENTIFIER, CHARGE_START_DATE, CHARGE_END_DATE, TOT_INT_AMT_OVER_25P) values (2000000000, to_date (30 December 05 00.00.00','DD-MON-RR HH24.MI.)) To_date SS'), (31 January 06 00.00.00','DD-MON-RR HH24.MI.) SS'), 5.51555);

    Query, I used:

    SELECT A.MI_ACC_IDENTIFIER, A.CHARGE_START_DATE, A.CHARGE_END_DATE, NVL (B.PBA_INT_AMT, 0), a.TOT_INT_AMT_OVER_25P OF
    TABLE_2 A, B FROM TABLE_1
    WHERE A.MI_ACC_IDENTIFIER = B.MI_ACC_IDENTIFIER (+)
    AND A.CHARGE_START_DATE = B.CHARGE_START_DATE (+)
    AND A.CHARGE_END_DATE = B.CHARGE_END_DATE (+)
    and A.TOT_INT_AMT_OVER_25P > B.PBA_INT_AMT (+);

    I have been using the syntax of ANSI join for some time. They are readable and code looks more elegant. A reason do not want to use it?

    I don't care

    SQL> select t2.mi_acc_identifier
      2       , t2.charge_start_date
      3       , t2.charge_end_date
      4       , nvl(t1.pba_int_amt, 0) pba_int_amt
      5       , t2.tot_int_amt_over_25p
      6    from table_1 t1
      7       , table_2 t2
      8   where t1.mi_acc_identifier (+)= t2.mi_acc_identifier
      9     and t1.charge_start_date (+)= t2.charge_start_date
     10     and t1.charge_end_date   (+)= t2.charge_end_date
     11     and (t1.pba_int_amt < t2.tot_int_amt_over_25p     or t1.mi_acc_identifier is null);
    
    MI_ACC_IDENTIFIER CHARGE_ST CHARGE_EN PBA_INT_AMT TOT_INT_AMT_OVER_25P
    ----------------- --------- --------- ----------- --------------------
           2000000000 01-NOV-05 30-NOV-05         .34               .81756
           2000000000 30-DEC-05 31-JAN-06        1.92              5.51555
           2000000000 01-DEC-05 29-DEC-05           0               .64724
    
    SQL>
    
  • left and right outer join

    Hi gurus,

    Left outer join:

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

    Select * from A LEFT OUTER JOIN B on A.col = B.col;

    by definition, a left outer join brings the rows that match the join condition and lines not corresponding to table A.

    My question here is "corresponding to B and no matching rows in A" is that nothing, but... SELECT * FROM A;

    can someone pls clarity...

    Thank you.

    Imagine that you had:

    TableA

    COLUMN1 COLUMN2

    'A'                1

    'B'                2

    'C'                3

    TABLEB

    COLUMN1 COLUMN2

    'A'                 'X1'

    'A'                 'X2'

    'B'                 'Y'

    'D'                 'Z'

    SELECT * FROM TABLEA;

    A 1

    B 2

    C 3

    Now, if you want to join (first column is either in table A or B, (deuxieme from tableA, third table B)

    SELECT * FROM TABLEA A JOIN TABLEB B ON (A.COLUMN1 = B.COLUMN1)

    A 1 X 1

    A 1 X 2

    B 2 Y

    SELECT * FROM TABLE LEFT B EXTERNAL ON (A.COLUMN1 = B.COLUMN1) JOIN TABLE

    A 1 X 1

    A 1 X 2

    B 2 Y

    C 3 {null}

    SELECT * FROM TABLE A TABLE RIGHT OUTER JOIN B (A.COLUMN1 = B.COLUMN1)

    A 1 X 1

    A 1 X 2

    B 2 Y

    D {null} Z

    SELECT * FROM TABLE A TABLE FULL OUTER JOIN B (A.COLUMN1 = B.COLUMN1)

    A 1 X 1

    A 1 X 2

    B 2 Y

    C 3 {null}

    D {null} Z

    HTH

Maybe you are looking for