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:

Tags: ColdFusion

Similar Questions

  • 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

  • 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 and the where clause for the table to the right

    I want to join two tables a and b, where a is a must and b is a result set in option. When I use a left outer join to a to b, I want to achieve:

    1. Select a single column, two columns of b (not the join columns)
    2 - even if theres no friendly on the join column does not return data from one.
    3. If there is a match applies when the criteria on column b (table in option)

    so, how can I avoid no_data_found in this case? When I apply where criteria for b, so it does not return the data from one, which is a must.

    Sounds like a regular outer join to me...

    select a.col1, b.col2, b.col2
    from   tableA a
           left outer join tableB b
           on (a.id = b.id and b.colX = 'X')
    
  • Outer joins and null in the 'where' clause condition

    Hi people,

    Please help me on this.

    Here's my query.

    with x

    (select 'a' as a dual union all col1)

    Select 'b' as col1 of union double all the

    Select 'c' as double col1

    ),

    y as

    (

    Select 'b' as col2 from dual Union all the

    Select 'c' as col2 from dual Union all the

    Select would be "as col2 from dual Union all the"

    Select 'e' as col2 from dual

    )

    Select * x y right outer join

    on x.col1 = y.col2 and y.col2 is null

    Get all the lines of 'COL1' as null. Why like this?

    Just add the condition to the WHERE clause for example

    WITH x AS
    (SELECT 'a' AS col1 FROM dual UNION ALL
    SELECT 'b' AS col1 FROM dual UNION ALL
    SELECT 'c' AS col1 FROM dual
    ),
    y AS
    (
    SELECT 'b' AS col2 FROM dual UNION ALL
    SELECT 'c' AS col2 FROM dual UNION ALL
    SELECT 'd' AS col2 FROM dual UNION ALL
    SELECT 'e' AS col2 FROM dual
    )
    SELECT * FROM x LEFT OUTER JOIN y
    ON x.col1=y.col2                     ----want to add "and y.col2 is null " condition to get value "a"
    where y.col2 is null
    
  • Outer Join and joining several Tables

    Hello

    Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product

    I have three tables AddProject, AssociateProjectLead, AddAssociate. Now I'm generating a report who will join AddProject and AssociateProjectLead for a list of all the projects, even if it doenst have a project coordinator. I used the outer join for this. However, if I want the name of the project leader, I need to search for AddAssociate table. By joining this table also, the outer join is no longer valid. Please see the result below

    CREATE TABLE  "ADDPROJECT" 
       (     "VERSIONNO" NUMBER(*,0), 
         "PROJID" VARCHAR2(20), 
         "PROJNAME" VARCHAR2(60), 
         "PROJSTARTDATE" DATE, 
         "PROJSTATUS" VARCHAR2(20), 
         "PROJENDDATE" DATE, 
         "PROJENDTYPE" VARCHAR2(20), 
         "PROJENDREASON" VARCHAR2(1000), 
         "UCPROJECTMANAGER" VARCHAR2(20), 
         "FROMDATE" DATE, 
         "TODATE" DATE, 
         "SRCHFIELD" VARCHAR2(20), 
         "OPERATOR" VARCHAR2(20), 
         "PARENTPROJID" VARCHAR2(20), 
         "PROJHIDDENDATE" VARCHAR2(20), 
          CONSTRAINT "PK_B36" PRIMARY KEY ("PROJID", "PROJHIDDENDATE") ENABLE
       )
    
    
    CREATE TABLE  "ADDASSOCIATE" 
       (     "VERSIONNO" NUMBER(*,0), 
         "ASSOCIATEID" NUMBER(9,0) NOT NULL ENABLE, 
         "ASSOCIATENAME" VARCHAR2(100) NOT NULL ENABLE, 
         "CTOJOINDATE" DATE, 
         "STATUS" VARCHAR2(20), 
         "ENDDATE" DATE, 
         "SRCHFIELD" VARCHAR2(20), 
         "OPERATOR" VARCHAR2(20), 
         "FROMDATE" DATE, 
         "TODATE" DATE, 
          CONSTRAINT "PK_B23" PRIMARY KEY ("ASSOCIATEID") ENABLE
       )
    
    CREATE TABLE  "ASSOCIATEPROJECTLEAD" 
       (     "VERSIONNO" NUMBER(*,0), 
         "PROJLEADASSOID" NUMBER(9,0), 
         "PROJID" VARCHAR2(20), 
         "ASSOCIATEID" NUMBER(9,0), 
         "PROJLEADSTARTDATE" DATE, 
         "STATUS" VARCHAR2(20), 
         "ASSOCPROJHIDDENDATE" VARCHAR2(20), 
         "PROJHIDDENDATE" VARCHAR2(20), 
         "ENDDATE" DATE, 
          CONSTRAINT "PK_B40" PRIMARY KEY ("ASSOCIATEID", "PROJID", "ASSOCPROJHIDDENDATE") ENABLE
       )
    
    
    elect ap.projid,apl.associateid
    from addproject ap, associateprojectlead apl
    where ap.projid = apl.projid(+)
    and ap.projhiddendate = apl.projhiddendate(+)
    
    
    PROJID ASSOCIATEID 
    Proj08 75825 
    Proj09 75825 
    Proj10 75825 
    Proj11 75825 
    Proj12 259811 
    Proj01 103035 
    Proj02 103035 
    Proj03 320092 
    Proj04 320092 
    Proj05 120974 
    Proj06 367393 
    Proj07 117618 
    Proj07 224882 
    Proj07 246652 
    prj001 -  
    prj001 -  
    
    16 rows returned in 0.00 seconds
    
    
    select ap.projid,apl.associateid,aa.associatename
    from addproject ap, associateprojectlead apl,addassociate aa
    where ap.projid = apl.projid(+)
    and ap.projhiddendate = apl.projhiddendate(+)
    and apl.associateid = aa.associateid
    
    
    PROJID ASSOCIATEID ASSOCIATENAME 
    Proj11 75825 Amarendra Kumar Singh 
    Proj10 75825 Amarendra Kumar Singh 
    Proj09 75825 Amarendra Kumar Singh 
    Proj08 75825 Amarendra Kumar Singh 
    Proj02 103035 Rajesh Jayaprakash 
    Proj01 103035 Rajesh Jayaprakash 
    Proj07 117618 Chetan Malhotra 
    Proj05 120974 Perumal Rajaram 
    Proj07 224882 Dilshad Ahmad 
    Proj07 246652 Shankar Kausley 
    Proj12 259811 Arunchandar Arun Vasan 
    Proj04 320092 Venkatesh Sarangan 
    Proj03 320092 Venkatesh Sarangan 
    Proj06 367393 Venkata Ramakrishna P 
    
    14 rows returned in 0.00 seconds
    How can I select all the values in table AddProject?

    Published by: Pramukh on August 23, 2012 12:18

    Hello

    I could get the result with a bit of modification

    select ap.projid,
           apl.associateid,
           aa.associatename
      from addproject ap
           left outer join
           associateprojectlead apl
        on ap.projid = apl.projid
       and ap.projhiddendate = apl.projhiddendate
           left outer join
           addassociate aa
        on apl.associateid = aa.associateid
    

    As a follow-up, I have a request more. In the report form, the user can select a particular project ID and the report should be generated as a result. For example;-he wants to see the results of the only "Proj08". I get the output as below, while the result should display only the details of 'Proj08 '.

    select ap.projid,
           apl.associateid,
           aa.associatename
      from addproject ap
           left outer join
           associateprojectlead apl
        on ap.projid = apl.projid
       and ap.projhiddendate = apl.projhiddendate
       and ap.projID = 'Proj08'
           left outer join
           addassociate aa
        on apl.associateid = aa.associateid
    ORDER BY ap.projID
    
    PROJID ASSOCIATEID ASSOCIATENAME
    Proj01 -  -
    Proj02 -  -
    Proj03 -  -
    Proj04 -  -
    Proj05 -  -
    Proj06 -  -
    Proj07 -  -
    Proj08 75825 Amarendra Kumar Singh
    Proj09 -  -
    Proj10 -  -
    Proj11 -  -
    Proj12 -  -
    prj001 -  -
    prj001 -  -  
    
  • outer join and OR condition

    Hello world

    I have a query that is not working properly. I'm trying to join two tables and I or condition and outer join
    I get the error message
     ORA-01719: outer join operator (+) not allowed in operand of OR or IN
    
    my query is as follow
    
    SELECT l.* FROM table1 l, table2 map
    WHERE (NVL(l.id, '-99') = NVL(map.id(+), NVL(l.id, '-99'))
            AND  l.TYPE = 'TKE')
          ) OR 
        (NVL(l.id, '-99') = NVL(map.id(+), NVL(l.id, '-99'))
    AND NVL(l.type, '-99') = NVL(map.type(+), NVL(l.type, '-99'))
    AND NVL(l.pos_22, '-99') = NVL(map.pos_22(+),NVL(l.pos_22, '-99'))
    AND NVL(l.pos_27, '-99') = NVL(map.pos_27(+),NVL(l.pos_27, '-99'))
    AND NVL(l.pos_17, '-99') = NVL(map.pos_17(+),NVL(l.pos_17, '-99'))
    AND NVL(l.pos_18, '-99') = NVL(map.pos_18(+),NVL(l.pos_18, '-99'))
    AND NVL(l.pos_12, '-99') = NVL(map.pos_12(+),NVL(l.pos_12, '-99'))
    AND NVL(l.pos_16, '-99') = NVL(map.pos_16(+),NVL(l.pos_16, '-99'))
    AND NVL(l.pos_34, '-99') = NVL(map.pos_34(+),NVL(l.pos_34, '-99'))
    AND NVL(l.pos_43, '-99') = NVL(map.pos_43(+),NVL(l.pos_43, '-99'))
    AND NVL(l.pos_14, '-99') = NVL(map.pos_14(+),NVL(l.pos_14, '-99'))
    AND NVL(l.status_cd, '-99') = NVL(map.status(+),NVL(l.status_cd, '-99'))
    AND NVL(l.action_cd,'-99') = NVL(map.action_cd(+), NVL(l.action_cd,'-99'))
    AND NVL(l.sys,'-99') = NVL(map.sys(+), NVL(l.sys,'-99'))
    AND NVL(l.ind,'-99') = NVL(map.ind(+), NVL(l.ind,'-99'))
      )
    So, basically in the above query I say that if the type = "TKE" do not join on all columns of pos. If type is not TKE then do all the joints on all columns POS etc.
    How do I rewrite query so that I can use OR and the outer JOIN in the same query?

    Hello

    It is one of several good reasons to use the ANSI join syntax. Move all the join conditions in the clause on, not the WHERE clause, and you do not use the sign +.

    SELECT  l.*
    FROM           table1 l
    LEFT OUTER JOIN  table2 map  ON   (    NVL(l.id, '-99') = COALESCE (map.id, l.id, '-99')
                                        AND  l.TYPE = 'TKE'
                          )
                                 OR  (     NVL (l.id, '-99') = COALESCE (map.id, l.id, '-99')
                              AND   NVL (l.type, '-99') = COALESCE (map.type), l.type, '-99')
                         ...
    

    Instead of nesting the NVL statements, use COALESCE, as illustrated above. It is independent of the issue of the join.

  • Left Outer Join DR.

    Hi Experts,

    I have a requirement that says - see the chart for the past 10 days, regardless the presence data table in fact.
    Lets consider an example - Time_dim product, are my dimension tables, Purchase_Order is my fact table.

    I did it for external Purchase_Order in left RPD with TIME_DIM and inner join with the PRODUCT table.  and execution of query of exit-
    Select T.Date, P.item, count (distinct PO.order_no)
    TIME_DIM t, PRODUCT P, PURCHASE_ORDER PO
    where T.date_key = PO.date_key
    and P.item = in. agenda
    and P.item = 'laptop ';

    The query generated by OBIEE left outer join, but when the condition P.item = "Notebook" included in the query, and if there are no orders for this product in one of the date, that date will not come in the result set.

    the query to be generated by the OBIEE is-


    Select T.Date, PO.item, count (distinct PO.order_no)
    TIME_DIM t,.
    (SELECT P.ITEM, IN. ORDER_NO
    PRODUCT P, PO PURCHASE_ORDER
    WHERE P.item = in. agenda
    and P.item = 'Laptop') IN.
    WHERE T.date_key = PO.date_key (+);

    How to design the RPD to achieve this. All pray to advise on this. Thanks in advance.

    Thank you
    Chantal

    Hello

    You are on 11.1.1.7?

    I would say that your condition can be made without using external and maintenance of product and the standard between the FACT dimension, time inner join join.

    If you enable your property analysis OBIEE "Include Null values" will automatically return all the elements of time and product matching your filter (so you'll need to add a filter on 'Date' to limit it to the last 10 days or you will have a unique day of your time dimension).

    If you filter then on "Laptop", even if there is not a single value in order for "Laptop" in the last 10 days, he will be there on the screen.

    Easy, clean and you keep your inner join between the facts and Dimensions.

    Take a look at this example, I just did on SampleApp 406:

    Selection of 12 months (year 2010) and a customer (id = 89) and income. The model has only an inner join. I activate the option "Include Null values" and here is the result.

    A line with cells only empty because there is not a single revenue for customer 89 in 2010. This is exactly your condition.

    Honestly, do not touch your model using the outer join, you will have more side effects than benefits. Every single scan will do the outer join and you'll have a lot of data 'empty' return of the DB (more large data set containing just the null values) and probably you need the outer join in 15 to 25% of your analysis.

    Keep things simple, it will be faster and easier to maintain.

  • Left outer join error 2

    Hi all

    11.2.0.1

    I have two 2 left outer join in my application, but I got errror

    Ths is supported?

    It is something like:

    Select tab1, b.col1, a.col1, c.col1 one

    LEFT OUTER JOIN tab2 b

    ON a.id = b.id;

    LEFT OUTER JOIN tab 3 c

    ON a.id = c.id;

    My syntax is correct? I got the error ora-942.

    Help, please...

    Thank you

    Then use script below

    SELECT A.ACRNUMBER AS ACR_NO, A.LASTNAME, A.GIVENNAME AS FIRSTNAME, A.MIDDLENAME, A.BIRTHDATE, A.GENDER,NLV2(F.COUNTRYID3,'XXX'), A.PROBSTAYLENGTH AS PROB_STAY_LENGHT,A.SECTIONISSUED AS SECTION_ISSUED, A.RESIDENCECERTIFICATENUMBER AS RESIDENCE_CERTIFICATE_NO, A.ACTIVESTATUS AS STATUS, B.CLIP
    IMAGE AS PHOTO, C.SIGBMP AS SIGNATURE,D.CARDISSUErNUMBER AS CARD_NO, D.CARDEXPIRYDATE AS CARD_VALIDITY, D.CARDSERIALNUMBER AS CARD_SERIAL_NO, D.CARDISSUEDATE AS CARD_DATE_ISSUED, nvl2( d.CARDSERIALNUMBER,'0','1') AS CARD_STATUS
           From   Acrmaster  A Inner Join  Pictures  B  On A.Acrnumber=B.Acrnumber
                           Inner Join  Signature  C On B.Acrnumber=C.Acrnumber
                           Inner Join  Acrcarddetails D On   C.Acrnumber=D.Acrnumber
                           Left Outer Join Acrblockcarddetails E On (D.Acrnumber=E.Acrnumber And D.Cardserialnumber=E.Cardserialnumber)
                           Left Outer Join Countrymaster_Lk F ON  A.NATIONALITY=F.ID
    

    You have error here:

    left outer join ACRBLOCKCARDDETAILS E

    Left Outer join Countrymaster_Lk F on d.acrnumber = e.acrnumber and d.CARDSERIALNUMBER = e.CARDSERIALNUMBER and A.NATIONALITY = F.ID

    Concerning

    Mr. Mahir Quluzade

  • Performance of outer join problem

    Dear all,

    Please help me in the development the sub query as it is particularly the outer join and goes for full scan of the table.

    Query:
    SELECT
    T27. CONFLICT_ID,
    T27. LAST_UPD,
    T27. CREATED,
    T27. LAST_UPD_BY,
    T27. CREATED_BY,
    T27. MODIFICATION_NUM,
    T27. ROW_ID,
    T24. ATTRIB_39,
    T27. REMIT_ADDR_ORG_ID,
    T27. REMIT_ORG_EXT_ID,
    T16.NAME,
    T25. ACCNT_TYPE_CD,
    T27. RECAL_TAX_SRV_FLG,
    T27. PROJ_ID,
    T8. PROJ_NUM,
    T8. BU_ID,
    T5.NAME,
    T8. INTEGRATION_ID,
    T12. CURCY_CD,
    T25. PR_BL_ADDR_ID,
    T25. URL,
    T27. TTL_INVC_AMT,
    T27. INVC_TYPE_CD,
    T27. TTL_PD_AMT,
    T3. CG_ASSSET_ID,
    T17. ASSET_NUM,
    T27. VENDR_INVOICE_NUM,
    T4. TOT_QTY_SHIP,
    T4. TOT_EXTND_PRICE,
    T27. ACCNT_ID,
    T25. INTEGRATION_ID,
    T25.NAME,
    T25. BU_ID,
    T25. AVAIL_CREDIT_AMT,
    T10.NAME,
    T27. AGREEMENT_ID,
    T4. TOT_EXTND_TAX,
    T27. STMT_SOURCE_CD,
    T4. SRC_INVLOC_ID,
    T27. STATUS_CD,
    T4. TOT_QTY_BONUS,
    T27. X_DEPOSIT_AMT,
    T27.COMMENTS,
    T27. INVC_FULLY_PAID_DT,
    T26. SEQ_NUM,
    T27. ELEMENT_ID,
    T26. INSCLM_ID,
    T14. INSCLAIM_NUM,
    T27. BL_PER_ID,
    T27. INS_CLAIM_ID,
    T27. FN_ACCNT_ID,
    T27. CUSTOMER_REF_NUM,
    T27. TTL_NONREC_AMT,
    T25. OU_NUM,
    T24. ATTRIB_39,
    T27. AMT_CURCY_CD,
    T2. CCNUM_ENCRPKEY_REF,
    T18. PR_DEPOSIT_ID,
    T19. DISCNT_RULE_CD,
    T27. ORDER_ID,
    T4. STATUS_CHG_FLG,
    T25. MAIN_PH_NUM,
    T25. MAIN_FAX_PH_NUM,
    T27. DELINQUENT_FLG,
    T15. OPENING OF SESSION
    T25. PR_POSTN_ID,
    T4. ORDER_NUM,
    T22. ADDR,
    T22. Zip code
    T27. INVC_NUM,
    T27. INVC_DT,
    T22. COUNTRIES,
    T22. CITY,
    T27. BL_ADDR_ID,
    T23.NAME,
    T27. POSTED_DT,
    T20.NAME,
    T27. BL_PERIOD_ID,
    T27. GOODS_DLVRD_TS,
    T23.NET_DAYS,
    T27. PAYMENT_TERM_ID,
    T23. DUE_DT,
    T27. DUE_DT,
    T27. VOID_REASON_TEXT,
    T27. DEPT_CD,
    T24. ATTRIB_60,
    T24. ATTRIB_28,
    T21. AMT,
    T1. STATE,
    T1. ADDR,
    T1. ADDR_LINE_2,
    T1. COUNTRIES,
    T1. CITY,
    T1. Zip code
    T11. OPENING OF SESSION
    T21. ROW_ID,
    T9. ROW_ID,
    T1. ROW_ID,
    T13. ROW_ID,
    T7. ROW_ID
    Of
    SIEBEL. S_ADDR_PER T1,
    SIEBEL. S_PTY_PAY_PRFL T2,
    SIEBEL. S_INVLOC T3,
    SIEBEL. S_ORDER T4,
    SIEBEL. S_ORG_EXT T5,
    SIEBEL. S_POSTN T6,
    SIEBEL. S_PARTY T7,
    SIEBEL. S_PROJ T8,
    SIEBEL. S_CON_ADDR T9,
    SIEBEL. S_ORG_EXT T10,
    SIEBEL. S_USER T11,
    SIEBEL. S_DOC_QUOTE T12,
    SIEBEL. S_ACCNT_POSTN T13,
    SIEBEL. S_INS_CLAIM T14,
    SIEBEL. S_USER T15,
    SIEBEL. S_ORG_EXT T16,
    SIEBEL. T17 S_ASSET,
    SIEBEL. S_ORDER_TNTX T18,
    SIEBEL. S_ORG_EXT_TNTX T19,
    SIEBEL. S_PERIOD T20,
    SIEBEL. S_DEPOSIT_TNT T21,
    SIEBEL. T22 S_ADDR_PER,
    SIEBEL. T23 S_PAYMENT_TERM,
    SIEBEL. S_ORG_EXT_X T24,
    SIEBEL. S_ORG_EXT T25,
    SIEBEL. S_INSCLM_ELMNT T26,
    SIEBEL. S_INVOICE T27
    WHERE
    T25. BU_ID = T10. PAR_ROW_ID (+) AND
    T26. INSCLM_ID = T14. ROW_ID (+) AND
    T27. ELEMENT_ID = T26. ROW_ID (+) AND
    T27. LAST_UPD_BY = T15. PAR_ROW_ID (+) AND
    T4. QUOTE_ID = T12. ROW_ID (+) AND
    T3. CG_ASSSET_ID = T17. ROW_ID (+) AND
    T27. BL_ADDR_ID = T22. ROW_ID (+) AND
    T8. BU_ID = T5. PAR_ROW_ID (+) AND
    T27. PER_PAY_PRFL_ID = T2. ROW_ID (+) AND
    T27. REMIT_ORG_EXT_ID = T16. PAR_ROW_ID (+) AND
    T27. PROJ_ID = T8. ROW_ID (+) AND
    T27. BL_PERIOD_ID = T20. ROW_ID (+) AND
    T27. PAYMENT_TERM_ID = T23. ROW_ID (+) AND
    T12. BU_ID = T19. PAR_ROW_ID (+) AND
    T27. ACCNT_ID = T25. PAR_ROW_ID (+) AND
    T27. ORDER_ID = T18. ROW_ID (+) AND
    T4. SRC_INVLOC_ID = T3. ROW_ID (+) AND
    T27. ORDER_ID = T4. ROW_ID (+) AND
    T27. ACCNT_ID = T24. PAR_ROW_ID (+) AND
    T18. PR_DEPOSIT_ID = T21. ROW_ID (+) AND
    T27. BL_ADDR_ID = T9. ADDR_PER_ID (+) AND
    T27. ACCNT_ID = T9. ACCNT_ID (+) AND
    T27. BL_ADDR_ID = T1. ROW_ID (+) AND
    T25. PR_POSTN_ID = T13. POSITION_ID (+) AND
    T25. ROW_ID = T13. OU_EXT_ID (+) AND
    T13. POSITION_ID = T7. ROW_ID (+) AND
    T13. POSITION_ID = T6. PAR_ROW_ID (+) AND
    T6. PR_EMP_ID = T11. PAR_ROW_ID (+) AND
    (T27. INVC_TYPE_CD =: 1) AND
    (T27. DEPT_CD =: 2);


    Explan exit Plan:
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Hash value of plan: 3132260827

    ---------------------------------------------------------------------------------------------------------------------------
    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
    ---------------------------------------------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | 1. 1958 | 1896K (11) | 00:50:46 |
    | 1. NESTED EXTERNAL LOOPS | 1. 1958 | 1896K (11) | 00:50:46 |
    | 2. NESTED EXTERNAL LOOPS | 1. 1922 | 1896K (11) | 00:50:46 |
    | 3. NESTED EXTERNAL LOOPS | 1. 1885 | 1896K (11) | 00:50:46 |
    | 4. NESTED EXTERNAL LOOPS | 1. 1861. 1896K (11) | 00:50:46 |
    | 5. NESTED EXTERNAL LOOPS | 1. 1849. 1896K (11) | 00:50:46 |
    | 6. NESTED EXTERNAL LOOPS | 1. 1817 | 1896K (11) | 00:50:46 |
    | 7. NESTED EXTERNAL LOOPS | 1. 1792 | 1896K (11) | 00:50:46 |
    | 8. NESTED EXTERNAL LOOPS | 1. 1771. 1896K (11) | 00:50:46 |
    | 9. NESTED EXTERNAL LOOPS | 1. 1739. 1896K (11) | 00:50:46 |
    | 10. NESTED EXTERNAL LOOPS | 1. 1483. 1896K (11) | 00:50:46 |
    | 11. NESTED EXTERNAL LOOPS | 1. 1451. 1896K (11) | 00:50:46 |
    | 12. NESTED EXTERNAL LOOPS | 1. 1419. 1896K (11) | 00:50:46 |
    | 13. NESTED EXTERNAL LOOPS | 1. 1361. 1896K (11) | 00:50:46 |
    | 14. NESTED EXTERNAL LOOPS | 1. 1276 | 1896K (11) | 00:50:46 |
    | 15. NESTED EXTERNAL LOOPS | 1. 1202 | 1896K (11) | 00:50:46 |
    | 16. NESTED EXTERNAL LOOPS | 1. 1108 | 1896K (11) | 00:50:46 |
    | 17. NESTED EXTERNAL LOOPS | 1. 1087 | 1896K (11) | 00:50:46 |
    | 18. NESTED EXTERNAL LOOPS | 1. 1040 | 1896K (11) | 00:50:46 |
    | 19. NESTED EXTERNAL LOOPS | 1. 939 | 1896K (11) | 00:50:46 |
    | 20. NESTED EXTERNAL LOOPS | 1. 894. 1896K (11) | 00:50:46 |
    | 21. NESTED EXTERNAL LOOPS | 1. 868. 1896K (11) | 00:50:46 |
    | 22. NESTED EXTERNAL LOOPS | 1. 843. 1896K (11) | 00:50:46 |
    | 23. NESTED EXTERNAL LOOPS | 1. 824. 1896K (11) | 00:50:46 |
    | 24. NESTED EXTERNAL LOOPS | 1. 690. 1896K (11) | 00:50:46 |
    | 25. NESTED EXTERNAL LOOPS | 1. 613. 1896K (11) | 00:50:46 |
    | 26. NESTED EXTERNAL LOOPS | 1. 457. 1896K (11) | 00:50:46 |
    | * 27. TABLE ACCESS FULL | S_INVOICE | 1. 269. 1896K (11) | 00:50:46 |
    | 28. TABLE ACCESS BY INDEX ROWID | S_PROJ | 1. 188. 1 (0) | 00:00:01 |
    | * 29. INDEX UNIQUE SCAN | S_PROJ_P1 | 1 | | 1 (0) | 00:00:01 |
    | 30. TABLE ACCESS BY INDEX ROWID | S_PAYMENT_TERM | 1. 156. 1 (0) | 00:00:01 |
    | * 31. INDEX UNIQUE SCAN | S_PAYMENT_TERM_P1 | 1 | | 1 (0) | 00:00:01 |
    | 32. TABLE ACCESS BY INDEX ROWID | S_INSCLM_ELMNT | 1. 77. 1 (0) | 00:00:01 |
    | * 33 | INDEX UNIQUE SCAN | S_INSCLM_ELMNT_P1 | 1 | | 1 (0) | 00:00:01 |
    | 34. TABLE ACCESS BY INDEX ROWID | S_INS_CLAIM | 1. 134. 1 (0) | 00:00:01 |
    | * 35 | INDEX UNIQUE SCAN | S_INS_CLAIM_P1 | 1 | | 1 (0) | 00:00:01 |
    | 36. TABLE ACCESS BY INDEX ROWID | S_PERIOD | 1. 19. 1 (0) | 00:00:01 |
    | * 37 | INDEX UNIQUE SCAN | S_PERIOD_P1 | 1 | | 1 (0) | 00:00:01 |
    | 38. TABLE ACCESS BY INDEX ROWID | S_USER | 1. 25. 2 (0) | 00:00:01 |
    | * 39 | INDEX UNIQUE SCAN | S_USER_U2 | 1 | | 1 (0) | 00:00:01 |
    | 40. TABLE ACCESS BY INDEX ROWID | S_ORDER_TNTX | 1. 26. 2 (0) | 00:00:01 |
    | * 41. INDEX UNIQUE SCAN | S_ORDER_TNTX_P1 | 1 | | 1 (0) | 00:00:01 |
    | 42. TABLE ACCESS BY INDEX ROWID | S_DEPOSIT_TNT | 1. 45. 1 (0) | 00:00:01 |
    | * 43. INDEX UNIQUE SCAN | S_DEPOSIT_TNT_P1 | 1 | | 1 (0) | 00:00:01 |
    | 44. TABLE ACCESS BY INDEX ROWID | S_ORDER | 1. 101 | 2 (0) | 00:00:01 |
    | * 45 | INDEX UNIQUE SCAN | S_ORDER_P1 | 1 | | 1 (0) | 00:00:01 |
    | 46. TABLE ACCESS BY INDEX ROWID | S_INVLOC | 1. 47. 1 (0) | 00:00:01 |
    | * 47 | INDEX UNIQUE SCAN | S_INVLOC_P1 | 1 | | 1 (0) | 00:00:01 |
    | 48. TABLE ACCESS BY INDEX ROWID | S_DOC_QUOTE | 1. 21. 1 (0) | 00:00:01 |
    | * 49 | INDEX UNIQUE SCAN | S_DOC_QUOTE_P1 | 1 | | 1 (0) | 00:00:01 |
    | 50. TABLE ACCESS BY INDEX ROWID | S_ORG_EXT_TNTX | 1. 94. 1 (0) | 00:00:01 |
    | * 51 | INDEX RANGE SCAN | S_ORG_EXT_TNTX_U1 | 1 | | 1 (0) | 00:00:01 |
    | 52. TABLE ACCESS BY INDEX ROWID | S_PTY_PAY_PRFL | 1. 74. 1 (0) | 00:00:01 |
    | * 53 | INDEX UNIQUE SCAN | S_PTY_PAY_PRFL_P1 | 1 | | 1 (0) | 00:00:01 |
    | 54. TABLE ACCESS BY INDEX ROWID | S_ADDR_PER | 1. 85. 2 (0) | 00:00:01 |
    | * 55 | INDEX UNIQUE SCAN | S_ADDR_PER_P1 | 1 | | 1 (0) | 00:00:01 |
    | 56. TABLE ACCESS BY INDEX ROWID | S_ADDR_PER | 1. 58. 1 (0) | 00:00:01 |
    | * 57 | INDEX UNIQUE SCAN | S_ADDR_PER_P1 | 1 | | 1 (0) | 00:00:01 |
    | 58. TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1. 32. 1 (0) | 00:00:01 |
    | * 59 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | 1 (0) | 00:00:01 |
    | 60. TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1. 32. 1 (0) | 00:00:01 |
    | * 61. INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | 1 (0) | 00:00:01 |
    | 62. TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1. 256. 2 (0) | 00:00:01 |
    | * 63. INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | 1 (0) | 00:00:01 |
    | 64. TABLE ACCESS BY INDEX ROWID | S_ACCNT_POSTN | 1. 32. 3 (0) | 00:00:01 |
    | * 65 | INDEX RANGE SCAN | S_ACCNT_POSTN_U1 | 1 | | 2 (0) | 00:00:01 |
    | 66. TABLE ACCESS BY INDEX ROWID | S_POSTN | 1. 21. 1 (0) | 00:00:01 |
    | * 67. INDEX UNIQUE SCAN | S_POSTN_U2 | 1 | | 1 (0) | 00:00:01 |
    | 68. TABLE ACCESS BY INDEX ROWID | S_USER | 1. 25. 2 (0) | 00:00:01 |
    | * 69 | INDEX UNIQUE SCAN | S_USER_U2 | 1 | | 1 (0) | 00:00:01 |
    | 70. TABLE ACCESS BY INDEX ROWID | S_ORG_EXT | 1. 32. 2 (0) | 00:00:01 |
    | * 71 | INDEX UNIQUE SCAN | S_ORG_EXT_U3 | 1 | | 1 (0) | 00:00:01 |
    | * 72 | INDEX UNIQUE SCAN | S_PARTY_P1 | 1. 12. 1 (0) | 00:00:01 |
    | 73. TABLE ACCESS BY INDEX ROWID | S_ASSET | 1. 24. 2 (0) | 00:00:01 |
    | * 74 | INDEX UNIQUE SCAN | S_ASSET_P1 | 1 | | 2 (0) | 00:00:01 |
    | 75. TABLE ACCESS BY INDEX ROWID | S_ORG_EXT_X | 1. 37. 2 (0) | 00:00:01 |
    | * 76 | INDEX RANGE SCAN | S_ORG_EXT_X_U1 | 1 | | 2 (0) | 00:00:01 |
    | 77. TABLE ACCESS BY INDEX ROWID | S_CON_ADDR | 1. 36. 3 (0) | 00:00:01 |
    | * 78 | INDEX RANGE SCAN | S_CON_ADDR_U1 | 1 | | 2 (0) | 00:00:01 |
    ---------------------------------------------------------------------------------------------------------------------------

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

    27 - filter("T27".") DEPT_CD "=: 2 AND"T27"". "" INVC_TYPE_CD "(=:1)"
    29 - access("T27".") PROJ_ID '= 'T8'.' ROW_ID "(+))"
    31 - access("T27".") PAYMENT_TERM_ID "="T23"." ROW_ID "(+))"
    33 - access("T27".") ELEMENT_ID "="T26"." ROW_ID "(+))"
    35 - access("T26".") INSCLM_ID "="T14"." ROW_ID "(+))"
    37 - access("T27".") BL_PERIOD_ID '= 'T20'.' ROW_ID "(+))"
    39 - access("T27".") LAST_UPD_BY "="T15"." PAR_ROW_ID "(+))"
    41 - access("T27".") ORDER_ID "="T18"." ROW_ID "(+))"
    43 - access("T18".") PR_DEPOSIT_ID "="T21"." ROW_ID "(+))"
    45 - access("T27".") ORDER_ID "="T4"." ROW_ID "(+))"
    47 - access("T4".") SRC_INVLOC_ID '= 'T3'.' ROW_ID "(+))"
    49 - access("T4".") QUOTE_ID "="T12"." ROW_ID "(+))"
    51 - access("T12".") BU_ID "="T19"." PAR_ROW_ID "(+))"
    53 - access("T27".") PER_PAY_PRFL_ID '= 'T2'.' ROW_ID "(+))"
    55 - access("T27".") BL_ADDR_ID '= 'T1'.' ROW_ID "(+))"
    57 - access("T27".") BL_ADDR_ID '= 'T22'.' ROW_ID "(+))"
    59 - access("T8".") BU_ID '= 'T5'.' PAR_ROW_ID "(+))"
    61 - access("T27".") REMIT_ORG_EXT_ID '= 'T16'.' PAR_ROW_ID "(+))"
    63 - access("T27".") ACCNT_ID '= 'T25'.' PAR_ROW_ID "(+))"
    65 - access("T25".") ROW_ID "= 'T13'." OU_EXT_ID "(+) AND 'T25'." ' PR_POSTN_ID '= "T13". "POSITION_ID" (+)) "
    67 - access("T13".") POSITION_ID "="T6"." PAR_ROW_ID "(+))"
    69 - access("T6".") PR_EMP_ID '= 'T11'.' PAR_ROW_ID "(+))"
    71 - access("T25".") BU_ID '= 'T10'.' PAR_ROW_ID "(+))"
    72 - access("T13".") POSITION_ID '= 'T7'.' ROW_ID "(+))"
    74 - access("T3".") CG_ASSSET_ID "="T17"." ROW_ID "(+))"
    76 - access("T27".") ACCNT_ID '= 'T24'.' PAR_ROW_ID "(+))"
    78 - access("T27".") BL_ADDR_ID "="T9"." ADDR_PER_ID "(+) AND 'T27'." "ACCNT_ID"= "T9". "ACCNT_ID" (+)) "
    filter ("T27". "ACCNT_ID"= "T9"." ACCNT_ID "(+))"

    117 selected lines.

    We use 10.2.0.3 oracle version.

    Hello

    According to the plan of the explain command, > 99% of the cost of the query comes from a single operation - step 27, a comprehensive analysis of the S_INVOICE table.
    This probably means that there is no index can be used on DEPT_CD and/or INVC_TYPE_CD.

    So start by setting SELECT * FROM S_INVOICE WHERE ("T27" T27. "DEPT_CD" =: 2 AND "T27" "." " INVC_TYPE_CD "(=:1)"

    BTW the plan shows that the 1 row should be returned, while Oracle actually returns 117 - this means that the optimizer estimates are not very reliable here.

    Best regards
    Nikolai

  • records with an outer join restrictions while using a sub query?

    I have the following code:

    declare

    Default char Activeonly ' n ';

    SearchKey varchar2 (15) default '413041494500064';

    number of lclAcctNo;

    Start

    Select

    rat_acct_no in lclAcctNo

    ACCT,.

    marketer_account ma1,

    Marketing agent,

    Account_Service,

    Account_Address

    Where (Rat_Acct_No = Mka_Acct_No

    and Mka_Exp_Dt = (ma2 select Max (Mka_Exp_Dt) of Marketer_Account

    Where Mka_Acct_No = Rat_Acct_No)

    and mka_service_type = 'E')

    And Rat_Acct_No = Acs_Acct_No

    And Rat_Acct_No = Add_Acct_No

    "And Add_Address_Type s ="

    And Rat_Full_Css_Acct_No as Trim (Searchkey) | '%'

    And (Activeonly is Null or Activeonly = ' or (Rat_Acct_Status_Cd = 'A' or Rat_Acct_Status_Cd is Null))

    and rownum < 1000;

    dbms_output.put_line ('Account' | lclAcctNo);

    end;

    I'm doing the table MARKETER_ACCOUNT (MKA_fields) an outer join, because the data I expect to will not be on the table, but I want even when the table of ACCT.

    I can't do an outer join on subqueries, so wanted to know if there was a way more easy/better to Edifier cela?

    I use Oracle 11.2 g.

    Thanks for any help.

    Sean

    Basically, I think, your outer join is ruined by the subquery correlated in the WHERE clause:

    R.ToDate = (Select MAX(ToDate) from R r2
    

    Since you joined outside R to A tell you the database to give you the lines of A for which R.ToDate is null * AND * meets your requirement: and this is not possible. Tom Kyte gave the classic explanation for this kind of problem long ago on AskTom: http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:4963137609733 ("ask yourself this - how a row in T2 (EMP in your example) the MISSING two (composed due to the outer join) AND have a column that corresponds to something?")  It cannot be").

    Here's your example in DDL + DML form: ''

    create table account)

    VARCHAR2 (10) key

    , name varchar2 (10)

    , status varchar2 (10)

    );

    insert into account values ('A1', 'John', 'Active');

    insert into account values ('A2', 'Mary', 'Active');

    insert into account values ('A3', 'James', 'Inactive');

    Create array of marketing)

    VARCHAR2 (10) key

    , Varchar2 (10) Mktr

    );

    insert into values Marketer ("M1", "ABC");

    insert into values Marketer ("M2", "DEF");

    create table relationship)

    VARCHAR2 (10) key

    , Varchar2 (10) AccKey

    , MktKey varchar2 (10)

    , FromDt varchar2 (10)

    , Varchar2 (10) so far

    );

    insert into the relationship values ('R1', 'A1', 'M1', "" 01/01/2012 ', December 31, 2012 ' ");

    insert into the relationship values ('R2', 'A1', 'M2', "01/01/2013 ', 'present'");

    insert into the relationship values ('R3', 'A2', 'M2', ' 01 /' 02/2013, 31 / 05/2013 ');

    Select B.SID

    M.Mktr

    R.FromDt

    R.ToDate

    account A

    left join

    relationship R

    on (a.Key = R.AccKey)

    left join

    Distributor M

    on (R.MktKey = M.Key)

    where R.ToDate = (Select MAX (r2. To date)

    relationship r2

    where r2. AccKey = A.Key)

    and A.Status = 'Active '.

    ;

    MKTR FROMDT NAME DATE

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

    Mary DEF 2/1/2013 5/31/2013

    John DEF 01/01/2013 presents

    -a possibility to obtain all the relevant lines would be to perform filtering after the join:

    with

    BaseData as)

    Select B.SID

    A.key

    M.Mktr

    R.FromDt

    R.ToDate

    account A

    left join

    relationship R

    on (a.Key = R.AccKey)

    left join

    Distributor M

    on (R.MktKey = M.Key)

    )

    Select basedata.*

    of basedata

    where basedata. ToDate = (Select MAX (r2. To date)

    relationship r2

    where r2. AccKey = basedata. Key)

    or basedata. This day is null;

    KEY MKTR FROMDT NAME DATE

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

    Mary A2 DEF 2/1/2013 5/31/2013

    John A1 DEF 01/01/2013 presents

    James A3

    Of course, there are many other possible solutions - since it's SQL...

    Concerning

    Martin

  • Right outer join

    There are four tables:

    Family
    Parent
    Child
    Grandchild

    Ideally, they have all documents, such as

    F1 - P1 - C1 - G1
    F2 - P2 - C2 - G2
    F3 - P3 - C3 - G3

    But sometimes,.

    F1 - P1 - C1 - null
    F2 - P2 - null - null
    F3 - P3 - null - null

    For the case of the latter, maybe I need to right outer join. If it's between two tables, the right outer join is easier. But among the four tables, inner family join parent, child of the outer join, then the big kid outer join. Maybe even this has been done? If an outer join in this case is not relevant, what other options are available?


    Thank you

    (ORACLE 11.2)

    Hello

    As Salomon, said

    FROM  p  LEFT  OUTER JOIN c
    

    means exactly the same thing that

    FROM  c  RIGHT OUTER JOIN p
    

    Everything you do with LEFT OUTER JOIN you could also do with RIGHT OUTER JOIN, and vice versa. If either one did not exist, you may do whatever you want with the other. In practice, it's just what's happening: most of the people always use LEFT OUTER JOIN and never use a RIGHT OUTER JOIN.

    You can have a series of outer joins cascading. If I understand your problem, a particular family may or may not have parents that belongs to him. If there are relatives, then you want to show the family with his parents to realteaed, but if there are no parents, so you want to show the family anyway. Similarly, you want to show parents whether or not they have children, and the children or not all my grandchildren are related to them. In general, which is written like this:

    ...
    FROM           family          f
    LEFT OUTER JOIN      parent          p    ON  p.family_id  = f.family_id
    LEFT OUTER JOIN      child          c    ON  c.parent_id  = p.parent_id
    LEFT OUTER JOIN      grandchild  g       ON  g.child_id   = c.child_id
    

    You can have a situation where (for example) a child is related to a family, but the child has no parent? In this case, you can still use LEFT OUTER JOIN, but join conditions would be different.

  • How to specify an outer join in the query designer

    I quickly built a large query with the query designer, and it works very well, but does not produce 9 disks on 2200 - so I need to change to an outer join.

    My problem is that I can't find a way to specify an outer join. I tried to change the query, query builder formed, but it won't let me.

    I know that I can capture the query, edit and run it in sql developer and that works fine, but I want to use the Query Builder as it is the fastest way I know to quickly add and remove items - my users don't know exactly what that it to include.

    I know it's kind of a trivial question, but I searched the forum, manual, the web and no luck

    Thanks for any help you can give

    Glenn

    Hi Glenn,.

    When you use the query designer to create the sql statement, you must click on the empty box to the right of the fields in each table to create the join. When you are finished, you should see a line drawn between the two tables. Click on this line, and a small window appears allowing you to select inner outer or right outer joins, left.

    When the report was created, however, you must change the statement. For example, if you use the query designer to join DEPT at EMP based on the DEPTNO field on the two tables, you get:

    select      "DEPT"."DEPTNO" as "DEPTNO",
          "DEPT"."DNAME" as "DNAME",
          "DEPT"."LOC" as "LOC",
          "EMP"."EMPNO" as "EMPNO",
          "EMP"."ENAME" as "ENAME",
          "EMP"."JOB" as "JOB",
          "EMP"."MGR" as "MGR",
          "EMP"."HIREDATE" as "HIREDATE"
     from      "EMP" "EMP",
          "DEPT" "DEPT"
     where   "DEPT"."DEPTNO"="EMP"."DEPTNO"
    

    This is to change:

    select      "DEPT"."DEPTNO" as "DEPTNO",
          "DEPT"."DNAME" as "DNAME",
          "DEPT"."LOC" as "LOC",
          "EMP"."EMPNO" as "EMPNO",
          "EMP"."ENAME" as "ENAME",
          "EMP"."JOB" as "JOB",
          "EMP"."MGR" as "MGR",
          "EMP"."HIREDATE" as "HIREDATE"
     from      "EMP" "EMP"
          LEFT OUTER JOIN "DEPT" "DEPT" ON "DEPT"."DEPTNO"="EMP"."DEPTNO"
    

    Andy

  • He had to know the right outer join using...

    He had to know the right outer join using...

    For example: first query left outer join for the emp table: SELECT EMPNO, ENAME, D.DEPTNO FROM EMP E, Department D WHERE the E.DEPTNO = D.DEPTNO)

    Second query left outer join for the Dept table: SELECT EMPNO, ENAME, D.DEPTNO FROM EMP E, Department D WHERE the D.DEPTNO = E.DEPTNO)

    In the example above I just Exchange where condition condition to get an outer join of two table with a left outer join itself. Wat is use right outer join, instead, I can swap the status of table name for the result. Please suggest...

    Hello

    chan001 wrote:

    He had to know the right outer join using...

    For example: first query left outer join for the emp table: SELECT EMPNO, ENAME, D.DEPTNO FROM EMP E, Department D WHERE the E.DEPTNO = D.DEPTNO)

    Second query left outer join for the Dept table: SELECT EMPNO, ENAME, D.DEPTNO FROM EMP E, Department D WHERE the D.DEPTNO = E.DEPTNO)

    In the example above I just Exchange where condition condition to get an outer join of two table with a left outer join itself. Wat is use right outer join, instead, I can swap the status of table name for the result. Please suggest...

    The two examples above use the old syntax outer join of Oracle. (I guess there should be a sign inside the parentheses, e.g.. +)

    ...  WHERE E.DEPTNO = D.DEPTNO (+)

    )

    The LEFT OUTER JOIN and RIGHT OUTER JOIN terms apply only to the ANSI join syntax, e. g.

    .

    .. FROM EMP E

    DEPT LEFT OUTER JOIN D ON E.DEPTNO = D.DEPTNO

    As Blushadow said above, there's no real point in having LEFT OUTER JOIN and RIGHT OUTER JOIN;  What you can do with one (or a combination of both) can be done with the other.  Most people use LEFT OUTER JOIN systematically and never use RIGHT OUTER JOIN.

    There are situations where using a combination of the two would mean a little less striking, but only a little less and this kind of situation is very common, and one may wonder if the somewhat shorter code is more specific.  I suggest that forget you RIGHT OUTER JOIN.

  • 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

Maybe you are looking for