How to Left Join?

I want to perform the following join to merge data from 3 tables. Can I do this using the JOIN operator or is there another way to achieve this result in OWB?
INSERT INTO MERGETABLE (L1, L2, L3, L4)
SELECT T2.L1, T2.L2, T3.L3, T4.L4 FROM T4
LEFT JOIN T3 ON T3.L3=T4.L3
LEFT JOIN T2 ON T2.L2=T3.L2

I seem to be able to achieve the desired result by JOINing T4 and T3 on T3.L3=T4.L3 into a table TEMP and then JOINing TEMP with T2 on TEMP.L2=T2.L2. However this seems to be more complicated than necessary. Can I achieve the same result in OWB in a single step as with the original SQL command?

Similar Messages

  • Query problem, two working queries how to left join together?

    Hello,
    I have a two queries that I have been trying to put together for a couple days. I'm frazzled. Hopefully you can help.
    The first query returns all rows from the database. The second query returns only one row (because the way it is currentlly set up in the Where clause). So I know that will have to change. For each row returned in Query1, I need the two fields from Query2 included
    (so the link would be through client.Id (which is an indexed field) or client.Accountnumber?
    This query, returns all records in the database:
    Select client.Id, client.accountnumber, client.Namelast,
    dmlocation.city ||', '||dmlocation.state as CityState,
    client.salesTerritory_client ||'-'|| dmuser.namefirst_user ||' '|| dmuser.namelast_user as Territory,
    MaxDates.LastRun, client.creditrisk, client.customercategory
    from client
    Left join fctclientcoverage on fctclientcoverage.client_id = client.id
    Left join dmlocation on fctclientcoverage.location_id = dmlocation.id
    Left join dmuser on dmuser.id = client.id
    Left join (Select to_char(Max(dmdate.calendardate),'MM/DD/YY') as LastRun, Client.Id
    from dmdate, client, fctadorder
    where dmdate.id = fctadorder.lastinsert_date_id and client.id = fctadorder.primaryorderer_client_id
    group by client.id) MaxDates ON client.id = MaxDates.Id
    where(fctclientcoverage.Ccoverrecordstopdate Is Null)
    Order by client.namelast;
    Query 2, only returns 1 row, so for each row returned above, the two fields selected in this query should accompany each row. But how to link these two selects using the client.accountnumber (or perhaps by dmcliet.id)?
    Select booked.CurRev, booked.LastRev from (
    Select (sum(Case When dmDate.CalendarDate >= '29-DEC-2008' and dmDate.CalendarDate < '
    Then fctinsertchargedetail.Amount_insertDetail Else 0 End)) As CurRev,
    (sum(Case When dmDate.CalendarDate >= '29-DEC-2007' and dmDate.CalendarDate < '
    Then fctinsertchargedetail.Amount_insertDetail Else 0 End)) As LastRev
    from fctAdorder
    Inner Join client On fctAdorder.primaryorderer_client_id = client.id
    Inner Join fctinsertion On fctAdorder.id=fctinsertion.fctAdorder_id
    Inner Join fctinsertchargesummary On fctinsertion.id=fctinsertchargesummary.insertion_id
    Inner Join dmDate On fctinsertion.insert_date_id=dmDate.id
    Inner Join fctinsertchargedetail On fctinsertchargesummary.id=fctinsertchargedetail.insertchargesummary_id
    WHERE client.accountnumber = '12345678' and
    dmDate.CalendarDate >= '29-DEC-2007' And dmDate.CalendarDate < ') booked;
    Thanks for your time.

    Yes, You are correct!
    I just recently got the query working with the aid of another forum.
    The sad part is, all though the first query took 11 seconds to return 180,000 rows (thats good); The second query took 4 minutes to calculate and return all it's rows (that's bad). Together the query ran for over 4 minutes. Way too slow.
    Being brand new to oracle I have to try and figure away to cut this time down. Perhaps I'm not considering something?
    I orginally brought into my .net app the results from the first query and then in the rowdatabound event I queried each row to get the information needed from the second query. That was way too slow also. It was recommended to try and return all needed data at once.
    I've been given a task to emulate a current application, (which I do not have access to it's code), that brings back all of this same information that I am using. It only takes them maybe 15 seconds to run, to bring back all. Of course they were experienced oracle sql developers.
    So I guess my next step is to try and improve that second query. Thanks for replying to this Frank. I'll be back. Are you or is anyone good at knowing how to optimzie queries? I'm reading a book now trying out suggestions. Nothing is working yet.
    thanks

  • How to generate a query involving multiple tables(one left join others)

    Hi, all,
    I want to query a db like these:
    I need all the demographics information(from table demo) and their acr info(from table acr), and their clinical info(from table clinical), and their lab info(from table lab).
    The db is like this:
    demo->acr: one to many
    demo->clinical info: one to many
    demo->lab info: one to many
    I want to get one query result which are demo left join acr, and demo left join clinical, and demo left join lab. I hope the result is a record including demo info, acr info, clinical info, and lab info.
    How could I do this in SQL?
    Thanks a lot!
    Qian

    Thank you very, very much!
    Actually, I need a huge query to include all the tables in our db.
    We are running a clinical db which collects the patients demographics info, clinical info, lab info, and many other information.
    The Demographics table is a center hub which connects other tables. This is the main architecture.
    My boss needed a huge query to include all the information, so others could find what they need by filtering.
    As you have found, because one patients usually has multiple clinical/lab info sets, so the result will be multiplied! the number of result=n*m*k*...
    My first plan is to set time point criteria to narrow all the records with one study year. If somebody needs to compare them, then I have to show them all.
    So I have to know the SQL to generate a huge query including as many tables as possible.
    I show some details here:
    CREATE TABLE "IMMUNODATA"."DEMOGRAPHICS" (
    "SUBJECTID" INTEGER NOT NULL,
    "WORKID" INTEGER,
    "OMRFHISTORYNUMBER" INTEGER,
    "OTHERID" INTEGER,
    "BARCODE" INTEGER,
    "GENDER" VARCHAR2(1),
    "DOB" DATE,
    "RACEAI" INTEGER,
    "RACECAUCASIAN" INTEGER,
    "RACEAA" INTEGER,
    "RACEASIAN" INTEGER,
    "RACEPAC" INTEGER,
    "RACEHIS" INTEGER,
    "RACEOTHER" VARCHAR2(50),
    "SSN" VARCHAR2(11),
    PRIMARY KEY("SUBJECTID") VALIDATE
    CREATE TABLE "IMMUNODATA"."ACR" (
    "ID" INTEGER NOT NULL,
    "THEDATE" DATE ,
    "SUBJECTID" INTEGER NOT NULL,
    "ACR_PAGENOTCOMPLETED" VARCHAR2(1000) ,
    "ACR_MALARRASHTODAY" INTEGER ,
    "ACR_MALARRASHEVER" INTEGER ,
    "ACR_MALARRSHEARLIESTDATE" DATE ,
    PRIMARY KEY("ID") VALIDATE,
    FOREIGN KEY("SUBJECTID") REFERENCES "IMMUNODATA"."DEMOGRAPHICS" ("SUBJECTID") VALIDATE
    CREATE TABLE "IMMUNODATA"."CLIN" (
    "ID" INTEGER NOT NULL,
    "THEDATE" DATE ,
    "SUBJECTID" INTEGER NOT NULL,
    "CLIN_PAGENOTCOMPLETED" VARCHAR2(1000) ,
    "CLIN_FATIGUE" VARCHAR2(20) ,
    "CLIN_FATIGUEDATE" DATE ,
    "CLIN_FEVER" VARCHAR2(20) ,
    "CLIN_FEVERDATE" DATE ,
    "CLIN_WEIGHTLOSS" VARCHAR2(20) ,
    "CLIN_WEIGHTLOSSDATE" DATE ,
    "CLIN_CARDIOMEGALY" VARCHAR2(20) ,
    PRIMARY KEY("ID") VALIDATE,
    FOREIGN KEY("SUBJECTID") REFERENCES "IMMUNODATA"."DEMOGRAPHICS" ("SUBJECTID") VALIDATE
    Other tables are alike.
    Thank very much!
    Qian

  • How can I add left join in the coding

    I intend to dynamic add left jion in my java class.
    so I write the coding like below:
    incident_id = svc_yokyu_id(+)
    (Both of them have been selected in the select sentence.)
    However, when I run the app, it will throw a sql error.(ora-01416)
    then I copy the error sql sentence and try to test it
    QRSLT WHERE (incident_id = svc_yokyu_id(+))--this is a error sql sentence.
    Finding that if I delete the left join,(+), the sql will run right,
    or I modify the sql like
    QRSLT WHERE incident_id in (Select svc_yokyu_id from xxfm_srl_sr_jc_relation xssjr where incident_id = xssjr.svc_yokyu_id(+)) , it run right as well.
    according to bussiness requestion, I can't write the coding like above,
    so, i don't know how to implement it.
    and i hope to your advice. thx

    Does a hand come out of the screen, grabbing you by the wrist, every time you try?
    Just guessing…
    Peter

  • How To do a LEFT JOIN in Oracle 8i

    Hello
    To explain my problem in a simple way: I have two tables, PROVA1 and PROVA2. Both have a primary key with two fields (CHIAVE1 amd CHIAVE2, numbers).
    I have to search for all records in A but not in B. In Oracle 8 LEFT JOIN is not available and I do not Know how doing it.
    I have read something about + operator, but I am not sure. What about:
    Select * from PROVA1 P1, PROVA2 P2 where
    (P1.CHIAVE1(+) = P2.CHIAVE1) and
    (P1.CHIAVE2(+) = P2.CHIAVE2) and
    (P2.CHIAVE1 IS NULL) and
    (P2.CHIAVE2 IS NULL)
    Thank you
    Garetano Recchi

    Gaetano, you're really close.
    The (+) sign goes near to the table where the records can be missed. In your example near P2 columns.
    Select *
      from PROVA1  P1,  PROVA2  P2
      where P1.CHIAVE1 = P2.CHIAVE1(+)
      and P1.CHIAVE2 = P2.CHIAVE2(+)
      and P2.CHIAVE1 IS NULL
      and P2.CHIAVE2 IS NULLYou can anyway use the minus operator
    Select *
      from PROVA1
      where (chiave1,chiave2) in (select chiave1, chiave2 from prova1 minus select chiave1, chiave2 from prova2);If you want to download a free book (in italiano) for oracle beginners go to
    My Oracle-related blog
    Max

  • How to create a left join view in se11??

    I would like to create a view which contains KNA1,KONA,KNVV,KNVH(four tables) , I want to use this view to create a search help for Tcode 'VBO3'.
    but when I join table KNVH, there is no data in view, because there is no customer hierarchy, so I want to create a left join view. could you please tell me how to create a left join view? Thank you very much.

    Hello,
    yes, in general, maint. view and help view could be created as outer join view.
    but it should obey relationship.
    my fourt tables:
    KONA -
    > I want to get agreement number and type from this table
    KNA1 -
    >I want to get customer name, city, country from this table
    KNVH -
    >I want to get customer hierarchy from this table.
    KNVV -
    >I want to get customer group 1 from this table.
    but in help view, I can only get relationship between KONA and KNA1.
    I could not find the relationship for KNVH and KNVV.
    if it's required to add a search help exit, then how to write the code in the function?
    Could somebody please give me any solutions? thank you.

  • How to make a customize form with optional parameter and left join

    Hi,
    I am trying to make a report with a left join. I also want ot have optional parameters in it.
    I am using the Create Reports From SQL Query method:
    SQL is :
    select ename, sal
    from scott.emp left join scott.dept
    on scott.emp.deptno = scott.dept.deptno
    where sal >= :lower_sal
    and sal <= :higher_sal;
    However, if I do it this way, I those 2 parameters are not optional.... How can I make them optional?
    If I use the Create Reports From Query Wizard method, I can make the parameters optional, but then I cannot do the left join...
    Thanks,
    Wilson

    hi,
    to catch null values on both sides I use:
    where nvl(sal,0) >= nvl(:lower_sal,nvl(sal,0))
    and nvl(sal,0) <= nvl(:higher_sal,9999999999)
    otherwise there will be no rows in the report where the value of sal is null, even if there are no selection criteria entered.
    regards Michael

  • How  to  do inner join ,outer join, left join ,right join by using infoset

    how  to  do inner join ,outer join, left join ,right join by using infoset

    Hi
    If you want to make  join ,outer join, left join ,right join then its possible if you are using ODS or direct infoobject (In BW3.5) and if you are using BI7.0 then you also make join ,outer join, left join ,right join with Cube also.
    For making join ,outer join, left join ,right join in infosets you just select your info provider then right click on your infoarea from context menu select info set after doing this one pop-up opens here u define your infoset technical name and give either ODS object name of infoobject name.
    After doing this next screen opens in right hand side your selectes ODS or infoobject shows in graphical format .
    and left hand side it shows one menu bar here you can select another ODS or infoobject for making join ,outer join, left join ,right join .just click on ODS button in menu bar and select ODS drag your selected ODS from Left to right after doing this your selected ODS shown in right hand side window in graphical format you just now after doing this you are able to make join ,outer join, left join ,right join for this first you select field from one ods and drag a line from 1 ods to second ods after doing this one arrow is created from one ods to another ods just right click on arrow  and make join ,outer join, left join ,right join in to your ODS.
    I think its clear how we can we make join ,outer join, left join ,right join in infoset.If you have any further query then welcome.
    Assign Points...............
    Thanks and regards
    Ankit modi

  • How to use LEFT JOIN in LINQ

    I have this query in Oracle and I am trying to write a Linq query for this below sql. There are 2 datatables DATA_TABLE1 and DATA_TABLE2. Both tables have 2 fields ID1 and ID2.
    SELECT A.ID1, A.ID2
    FROM DATA_TABLE1 A
    LEFT JOIN DATA_TABLE2 B
    ON A.ID1 = B.ID1 AND A.ID2 = B.ID2
    WHERE B.ID1 IS NULL OR B.ID2 IS NULL

    In order to see what query the data provider sent to the server you can do the following.
    Just after creating the data context place this line in the code.
    db.Database.Log = Console.Write;
    Then place a breakpoint after the next line of code, shown next.
    var
    a =
    db.product.Where(p
    =>
    p.Name.Contains(asKeyword)).ToList();
    Then run the application and when it hits the breakpoint open the Visual Studio Output window and the SQL sent to the server should be displayed.
    Fernando (MCSD)
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects
    and unknown namespaces.

  • How to do a left join to create a timesheet status report in Power View

    I am trying to create a very simple report in power view for Project Online. It's a timesheet status report that should show a list of resources, and the current status of their timesheet (in progress, not started, etc).
    In Excel, I created an odata connection with Resources and Timesheets, and set up the connection between them. So, I can now easily display a list of timesheets, and filter them by end date. Good. But this only displays rows where there is an existing timesheet.
    So resources who have not started a timesheet are not displayed. So, I need a "left join" in power view to display all resources, whether or not they have a timesheet for the period. (and, for the ones that do, I need to display fields from the timesheet,
    such as the status description.)
    Any suggestions?
    Mike G.

    Hi Mike,
    I'm not sure of what I'm suggesting since I got no instance to test it, but I'm wondering if the OLAP Cube "MSP_Project_Timesheet" wouldn't contain all resources of the enterprise pool with assignments (and not only resources that already submitted
    a timesheet) since it is a combination of the assignment timephased, resource timephased and EPM timesheet cubes.
    Hope this helps.
    Guillaume Rouyre - MBA, MCP, MCTS

  • How to implement left join for the below sql.

    i need to perform left join between inventory table and purchase table and inventory table with sales table.
    please let me know the syntax.
    SELECT Tbl_ProductGroupMaster.ProdName, Tbl_ProductGroupMaster.UnitNam, Tbl_Inventory.CrDate, Tbl_Inventory.QtyOpStk, Tbl_Inventory.QtyClStk, Tbl_Inventory.ExcShortage, purchase.SumOfNUnit, sales.SumOfQty
    FROM Tbl_ProductGroupMaster, Tbl_Inventory left join
    [SELECT Tbl_PurchaseMain.idate as p_idate, Tbl_PurchaseSub.Proid as proid,
    sum(Tbl_PurchaseSub.NUnit) AS SumOfNUnit
    FROM Tbl_PurchaseMain, Tbl_PurchaseSub WHERE Tbl_PurchaseMain.GID=Tbl_PurchaseSub.gid
    and format(cdate(Tbl_PurchaseMain.idate),'mm-dd-yyyy') between format(cdate('13-Sep-2009'),'mm-dd-yyyy') and
    format(cdate('02-Oct-2009'),'mm-dd-yyyy') GROUP BY
    Tbl_PurchaseMain.idate, Tbl_PurchaseSub.Proid]. AS purchase on (Tbl_Inventory.CrDate = purchase.p_idate)
    left join
    [SELECT Tbl_SalesMain.idate AS s_idate, Tbl_SalesSub.Proid, sum(Tbl_SalesSub.Qty) AS SumOfQty
    FROM Tbl_SalesMain, Tbl_SalesSub
    WHERE Tbl_SalesMain.SAID=Tbl_SalesSub.SAID And
    format(cdate(Tbl_SalesMain.idate),'mm-dd-yyyy') Between format(cdate('13-Sep-2009'),'mm-dd-yyyy') And
    format(cdate('02-Oct-2009'),'mm-dd-yyyy')
    GROUP BY Tbl_SalesMain.idate, Tbl_SalesSub.Proid]. AS sales on (Tbl_Inventory.CrDate = sales.s_idate)
    WHERE
    Tbl_ProductGroupMaster.PROID=Tbl_Inventory.proid AND
    Tbl_Inventory.PROID=purchase.proid and
    Tbl_Inventory.PROID=sales.proid and
    Tbl_Inventory.CrDate = '13-Sep-2009';
    thanks,
    Vinodh

    Completely unstested as you haven't given much information but do you mean something like this?
    WITH purchase
           AS (  SELECT   Tbl_PurchaseMain.idate AS p_idate,
                          Tbl_PurchaseSub.Proid AS proid,
                          SUM (Tbl_PurchaseSub.NUnit) AS SumOfNUnit
                   FROM   Tbl_PurchaseMain, Tbl_PurchaseSub
                  WHERE   Tbl_PurchaseMain.GID = Tbl_PurchaseSub.gid
                          AND format (cdate (Tbl_PurchaseMain.idate), 'mm-dd-yyyy') BETWEEN format (
                                                                                               cdate('13-Sep-2009'),
                                                                                               'mm-dd-yyyy'
                                                                                        AND  format (
                                                                                                cdate('02-Oct-2009'),
                                                                                                'mm-dd-yyyy'
               GROUP BY   Tbl_PurchaseMain.idate, Tbl_PurchaseSub.Proid),
        sales
           AS (  SELECT   Tbl_SalesMain.idate AS s_idate,
                          Tbl_SalesSub.Proid,
                          SUM (Tbl_SalesSub.Qty) AS SumOfQty
                   FROM   Tbl_SalesMain, Tbl_SalesSub
                  WHERE   Tbl_SalesMain.SAID = Tbl_SalesSub.SAID
                          AND format (cdate (Tbl_SalesMain.idate), 'mm-dd-yyyy') BETWEEN format (
                                                                                            cdate('13-Sep-2009'),
                                                                                            'mm-dd-yyyy'
                                                                                     AND  format (
                                                                                             cdate('02-Oct-2009'),
                                                                                             'mm-dd-yyyy'
               GROUP BY   Tbl_SalesMain.idate, Tbl_SalesSub.Proid)
    SELECT   Tbl_ProductGroupMaster.ProdName,
             Tbl_ProductGroupMaster.UnitNam,
             Tbl_Inventory.CrDate,
             Tbl_Inventory.QtyOpStk,
             Tbl_Inventory.QtyClStk,
             Tbl_Inventory.ExcShortage,
             purchase.SumOfNUnit,
             sales.SumOfQty
    FROM   Tbl_ProductGroupMaster,
           Tbl_Inventory LEFT OUTER JOIN purchase
                         ON Tbl_Inventory.CrDate = purchase.p_idate
                         LEFT OUTER JOIN sales
                         ON Tbl_Inventory.CrDate = sales.s_idate
    WHERE Tbl_ProductGroupMaster.PROID = Tbl_Inventory.proid
    AND   Tbl_Inventory.PROID = purchase.proid
    AND   Tbl_Inventory.PROID = sales.proid
    AND   Tbl_Inventory.CrDate = '13-Sep-2009';Cheers
    Ben
    http://www.munkyben.wordpress.com

  • How do u write a LEFT JOIN in Oracle Developer Forms 6i?

    I have 2 tables:PERSDET and EMP_MEDICAL_LTA
    PERSDET has EMP_ID,EMP_NAME n some other fields.
    EMP_MEDICAL_LTA has EMP_ID,FIELD1,FIELD2 n some other fields
    EMP_ID is the common field between these 2 tables.
    My requirement is to display all the EMP_NAME,that is-EMP_NAME which have field1 and field2 entries, as well as EMP_NAME which donot have field1 and field2 entries. I thought of using a LEFT join for this operation. The query I used is as follows:
    SELECT PERSDET.emp_id,PERSDET.emp_name,EMP_MEDICAL_LTA.field1,EMP_MEDICAL_LTA.field2 into emp_id,emp_name,m,l FROM
    PERSDET LEFT JOIN EMP_MEDICAL_LTA ON PERSDET.emp_id=EMP_MEDICAL_LTA.EMP_ID
    where …<some other joining conditions>;
    This query worked perfectly fine when I tried it running on the SQL prompt, but when I wrote it in a cursor in Oracle Forms 6i, it gave an error on the “LEFT” keyword!
    Is there any substitute for LEFT JOIN in Oracle Forms 6i???
    Please help!
    Thanks!

    hi,
    yes it is very much possible. and you query willbe as follows;
    SELECT PERSDET.emp_id,PERSDET.emp_name,EMP_MEDICAL_LTA.field1,EMP_MEDICAL_LTA.field2 into emp_id,emp_name,m,l FROM
    PERSDET where PERSDET.emp_id=EMP_MEDICAL_LTA.EMP_ID(+)
    where …<some other joining conditions>;
    yse, you just have to use (+) symble on the side where the join condition is not fullfilled. the 2 possibilites for your qury is PERSDET.emp_id=EMP_MEDICAL_LTA.EMP_ID(+)
    PERSDET.emp_id(+)=EMP_MEDICAL_LTA.EMP_ID
    you can execute both and suit your self.
    MohibMaan.

  • Left Join query: revisited... I have to explain at user meeting tomm. pls..

    Hi Everyone,
    Can someone pls shed some light on the situation below
    I am understanding alot of what Michael and Rod wrote.... with my prev. post of LEFT JOIN and testing for
    not null and doing a double Boolean OR etc.
    - but- AM NOT understanding why the IS NOT NULL works, without the double boolean OR
    Pls help... have to explain what left join means to user tomm. I'm going to demo the query below and
    not the one with the double boolean OR bec. maybe too much info to present at one sitting. tx, sandra
    =====================
    the query below is left joining the STUDENT table to
    HOLD table.
    The HOLD table - contains rows for students who have holds on their record.
    a student can have more than one hold (health, HIPAA, basic life saving course)
    BUT, for this query: I'm only interested that a hold exists, so I'm choosing MAX on hold desc.
    Selecting a MAX, helps me, bec. it reduces my join to a 1 to 1 relationship, instead of
    1 to many relationship.
    Before I posted this thread at all, the LEFT JOIN below testing for IS NOT NULL worked w/o
    me having to code IS NOT NULL twice....
    Is that because, what's happening "behind the scenes" is that a temporary table containing all max rows is being
    created, for which Discoverer has no predefined join instructions, so it's letting me do a LEFT JOIN and have
    the IS NOT NULL condition.
    I would so appreciate clarification. I have a meeting on Tues, for which I have to explain LEFT JOINS to the user
    and how they should create a query. I need to come up with rules.
    If I feel "clear", I asked my boss to buy Camtasia videocast software to create a training clip for user to follow.
    Also, if any Banner user would like me to email the DIS query to run on their machine, I would be glad to do so.
    thx sooo much, Sandra
    SELECT O100384.ACADEMIC_PERIOD, O100255.ID, O100384.ID, O100255.NAME, O100384.NAME, O100255.PERSON_UID, O100384.PERSON_UID, MAX(O100255.HOLD_DESC)
    FROM ODSMGR.HOLD O100255, ODSMGR.STUDENT O100384
    WHERE ( ( O100384.PERSON_UID = O100255.PERSON_UID(+) ) ) AND ( O100384.ACADEMIC_PERIOD = '200820' )
    GROUP BY O100384.ACADEMIC_PERIOD, O100255.ID, O100384.ID, O100255.NAME, O100384.NAME, O100255.PERSON_UID, O100384.PERSON_UID
    HAVING ( ( MAX(O100255.HOLD_DESC(+)) ) IS NOT NULL )
    ORDER BY O100384.NAME ASC

    Hi,
    OK, I will try to explain this. When you outer join table B to table A then the rows in table A which do not match any rows in table B will returned with NULL in the columns from the table B.
    Oracle uses the syntax ( +) for outer joins. Now if you add another condition using the ( +) syntax (as shown below) the condition will be processed before the table is joined. Therefore if table A does not match any rows in table B which have col2=1 then the row from table A will be returned with NULLs for the table B columns.
    SELECT A.col1, B.col1
    FROM A, B
    WHERE A.col1 = B.col1( +)
    AND B.col2( +)=1
    Now, if the condition B.col2=1 was used instead then the condition would be processed after the join and therefore the rows from table A that were joined to table B but did not meet the condition would not be returned by the query.
    This applies to a WHERE clause and to the HAVING clause, but with one exception. If you use the ( +) within a group function in a HAVING clause then the ( +) will have no affect because the condition must be processed after group by and group by can only be processed after the join. Therefore MAX(B.col2( +)) = 1 is processed after the join even through it uses the ( +) syntax.
    You cannot use an OR or an IN with the ( +) syntax because the meaning of the OR in this situation is ambiguous, is the OR done before or after the join. A query with an OR or IN in an outer will fail with an Oracle ORA-01719 error. Discoverer recognises this situation and removes the ( +) so that the error does not occur. However, without the ( +) the conditions are processed after the join.
    Using the ( +) with IS NULL, e.g. col2( +) IS NOT NULL works in the same way. You just have to remember that the col2( +) could be NULL as a result of the outer join and therefore if the condition is processed after the query then the IS NOT NULL will remove the outer joined rows.
    Hope that is clear.
    Rod West

  • Left joins on multi-million rows

    i have a simple query doing left joining on several tables, upward of 7 tables. each table has several hundred million rows.
    tblA is 1:M tblB and tblB is 1:M tblC and so on.
    how to tune a query liked that?
    sample query is
    select distinct
    a.col,b.col,c.col
    from tblA a left join tblB b
    on a.id=b.id
    and a.col is not null
    left join tblC
    on b.id=c.id
    and c.col > criteria
    thanks.

    hi
    a simple query is liked
    SELECT my_DEP.description,
    my_DEP.addr_id,
    hundredRowsTbl.address,
    5MillTbl.checkin_TIME,
    5MillTbl.checkout_TIME,
    hundredRowsTbl.ID2,
    5MillTbl.ID,
    5MillTbl.col2,
    my_DEP.col3,
    5MillTbl.col13,
    hundreds.desc,
    50mmTbl.col6,
    50mmTbl.col5,
    5MillTbl.col33
    FROM
    my.5MillTbl 5MillTbl
    LEFT OUTER JOIN
    my.50mmTbl 50mmTbl
    ON 5MillTbl.ID = 50mmTbl.ID
    LEFT OUTER JOIN my.hundreds hundreds
    ON 5MillTbl.banding =
    hundreds.banding
    INNER JOIN my.my_DEP my_DEP
    ON 5MillTbl.organization_ID = my_DEP.organization_ID
    INNER JOIN my.my_40millTbl
    ON 5MillTbl.seqID = my_40millTbl.seqID
    LEFT OUTER JOIN my.hundredRowsTbl hundredRowsTbl
    ON my_DEP.addr_id = hundredRowsTbl.ID2
    LEFT OUTER JOIN my.30millTbl 30millTbl
    ON my_DEP.organization_ID = 30millTbl.dept_id
    WHERE 1=1
    AND 5MillTbl.ID IS NOT NULL
    AND ( 5MillTbl.checkout_TIME >= TO_DATE ('01-01-2009 00:00:00', 'DD-MM-YYYY HH24:MI:SS')
    AND 5MillTbl.checkout_TIME <TO_DATE ('12-31-2010 00:00:00', 'DD-MM-YYYY HH24:MI:SS')
    AND ( 5MillTbl.col2 IS NULL
    OR NOT (5MillTbl.col2 = 5
    OR 5MillTbl.col2 = 6)
    AND 5MillTbl.ID IS NOT NULL
    AND 30millTbl.TYPE= '30'
    AND my_DEP.addr_id = 61

  • Left join (+) instead of "not in"

    Hi all!
    I've got statement with "where dig not in (840, 978)" string.
    How do I write statement without "not in" ?
    I thought about left join and "is not null", but don't know exactly how to use it.
    Any ideas?
    Thanks ahead.

    Here is my solution:
    select d.* from
    (select 111 as accountno, 840 as currencyid from dual
    union all
    select 222 as accountno, 978 as currencyid from dual
    union all
    select 333 as accountno, 826 as currencyid from dual ) d ,
    (select 840 as dig from dual
    union all
    select 978 as dig from dual ) j
    where d.currencyid = j.dig(+)
    and j.dig is null
    Thanks to all.

Maybe you are looking for

  • SOA Suite 11g on WLS: Admin console EM not accessible

    Hello everybody, I am trying to install and run a sample SOA composite using SOASuite11g. Here are steps i followed- 1> Created schemas using RCU 2> Installed using JDeveloper11.1.1. 1.0.exe, which has installed Weblogic server and Jdeveloper. 3> Cre

  • Scrollbar error

    Hi, I'm getting this error whenever I add scrollbar to a dynamic text box TypeError: Error #1009: Cannot access a property or method of a null object reference.           at test_fla::MainTimeline/__setProp___id0__Biography_Layer1_0()           at te

  • Transferring files from iMac to External Drive issues. Please help

    I have a 500gb Western Digital external hard-drive. I began using it on a PC, but got a Mac a couple of months ago. There are a couple of problems that I am encountering. First of all, the folders that I had on my external drive (music, movies etc.)

  • I don't have mozilla or firefox, so i don't know what this is all about or how /if it applies to me

    I got an email saying i should update my browser. i thought i'd get instructions. but it brought me to all this firefox and mozilla stuff. as far as i know i don't have either. should i ignore the email?

  • Changing desktop pictures locks system preferences

    Re MacBook Pro laptop (OS 10.7.5) Problem: Changing desktop pictures locks System Preferences If I try to open System Preferences, I get windows for the Change Desktop/Background and the whirling beach ball begins until I go to Activities Monitor to