More than Outer join

I have records in a table:
TASKS
=====
TASKID          TASKCD          
1000          AD
1001          AD
1002          AD
1010          EO
1011          EO
1012          EO
1013          EO
EOs tasks depends on AD tasks and we have this dependency relationship in other table:
DEPTASKS
TASKID          DEPID          DEPCD
1010          1000          COMPLIES
1011          1001          COMPLIES
I need to display those AD tasks that does not have any record in DEPTASKS i.e taskid = 1002 as well
as those that has record in DEPTASKS.I am able to get the those ADs using outer join that does not have entry in
DEPTASKS i.e
(select taskad.taskid adid, taskad.taskcd,taskeo.taskid eoid,taskeo.task_cd
from tasks adtask,
tasks eotask) adeo, deptasks
where
adeo.eoid = deptasks.taskid(+)
and deptasks.dep-task-id(+) = adid
Problem: I also have to use one more filter i.e
where DEPCD = 'COMPLIES'
I.E :
adeo.eoid = deptasks.taskid(+)
and deptasks.dep-task-id(+) = adid
and DEPCD = 'COMPLIES'
when I use this filter, it again filters those ADs which does not have records in DEPTASKS.
Any suggestion how to control this scenerio.

Any suggestion how to control this scenerio.Here's a suggestion to "control" this scenario.
SQL> @test3
SQL> --
SQL> with tasks as (
  2    select 1000 as taskid, 'AD' as taskcd from dual union all
  3    select 1001, 'AD' from dual union all
  4    select 1002, 'AD' from dual union all
  5    select 1010, 'EO' from dual union all
  6    select 1011, 'EO' from dual union all
  7    select 1012, 'EO' from dual union all
  8    select 1013, 'EO' from dual),
  9  deptasks as (
10    select 1010 as taskid, 1000 as depid, 'COMPLIES' as depcd from dual union all
11    select 1011, 1001, 'COMPLIES'    from dual union all
12    select 1013, 1002, 'DOESNOTCOMPLY' from dual)
13  --
14  select t.taskid as t_taskid, t.taskcd as t_taskcd,
15         d.taskid as d_taskid, d.depid  as d_depid, d.depcd as d_depcd
16  from tasks t, deptasks d
17  where t.taskid = d.taskid(+)
18  and d.depcd(+) = 'COMPLIES';
  T_TASKID T_TASKCD     D_TASKID    D_DEPID D_DEPCD
      1010 EO               1010       1000 COMPLIES
      1011 EO               1011       1001 COMPLIES
      1001 AD
      1002 AD
      1013 EO
      1000 AD
      1012 EO
7 rows selected.
SQL>
SQL>HTH
isotope

Similar Messages

  • More than one join condition for 2 tables in obiee

    Hello,
    I am using obiee 11g.
    There are 2 tables tableA and tableB where the join condition is like (tableA.col1=tableB.col1) or (tableA.col1 is null and tableB.col1 is null)
    where should i do these type of joins.
    I tried putting in physcial layer->f(x) but giving error like here only columns an d opertaors are allowed.
    Thanks

    ok here it goes.
    I have a tableA with columns col1(pk),col2 and other columns
    I have tableB with columns col1(pk),col2..Only these 2 columns.
    Now distinct tableA.col2 values are put in tableB.col2. For those distinct values i have put the tableB.col1 values.
    Now tableA.col2 as well as tableB.col2 can be null beacuse there may be null values in tableA.col2.
    Now in tableB i have added one more row which has col1 as value and col2 as null.
    Now when in physical layer when i do tableA.col2=tableB.col2 i dont get the null values.
    What i want is whenever the tableA.col2 and tableB.col2 is null then take tableB.col1 for those vales.
    So when i query i do
    select * from tableA,tableB where
    ((tableA.col2=tableB.col2) or (tableA.col2 is null and tableB.col2 is null))
    What i want is when i do a join i should be able to give this OR condition in rpd thats it.
    because when i do in where clause of content tab it goes like a AND condition and not OR.
    Thanks
    Edited by: user123 on Jul 5, 2011 1:57 PM

  • Oracle OUTER JOIN on more than one table

    Hi!
    Friends, please help with this urgent problem: How can an outer join be written on more than one table?
    An SQL Server query:
    SELECT * from a INNER JOIN b on a.id = b.id LEFT OUTER JOIN c ON c.id = a.id AND c.id = b.id
    works fine with SQL SERVER
    But Oracle query:
    SELECT * from a,b,c WHERE a.id = b.id AND a.id = c.id (+) AND b.id = c.id (+)
    gives an error: OUTER JOIN cannot be used on more than one table? Why?
    I use OracleDriver from classes12.zip to connect to Oracle8i database.
    Please, help!

    The Oracle 8i and later SQL reference reads that the following "join_types" are supported and under this syntax it does not limit the LEFT OUTER JOIN (syntax the same as SQLServer example in original note) to two tables as implied in these notes:
    The join_type indicates the kind of join being performed:
    Specify INNER to indicate explicitly that an inner join is being performed. This is the default.
    Specify RIGHT to indicate a right outer join.
    Specify LEFT to indicate a left outer join.
    Specify FULL to indicate a full or two-sided outer join. In addition to the inner join, rows from both tables that have not been returned in the result of the inner join will be preserved and extended with nulls.
    You can specify the optional OUTER keyword following RIGHT, LEFT, or FULL to explicitly clarify that an outer join is being performed.

  • How to use left outer join on more than one table (source)

    Hi all,
    In our project we are converting the Unix shell & SQL scripts into OWB mappings. We are facing problem converting left outer join in OWB. here is one of the example. i have just pasted the FROM and where condition.
    FROM ym_scr t1, branch_finmonth t3
    LEFT OUTER JOIN item_image t2
    ON (t1.branch_no = t2.branch_no
    AND t1.item_no = t2.item_no
    AND t3.to_date between t2.tran_dt and t2.to_dt
    AND t2.to_dt >= '$start_images' ) <<<========= '$start_images' THIS COMES FROM THE UNIX VARAIBLE ,
    We converts the same when we are putting it in OWB join Operator
    INGRP1.branch_no = INGRP2.branch_no(+)
    AND INGRP1.item_no = INGRP2.item_no(+)
    AND INGRP3.to_date between t2.tran_dt and t2.to_dt
    AND INGRP2.to_dt >= INGRP2.start_images
    But as you see in the OWB opreator we can put left join with INGRP1 with INGRP2.
    We can not make same join with INGRP3 & INGRP4 , becoz it failed saying "you cannot left outer join on more than one table/source".
    so overall this OWB code makes incomplete left outer join as per the above ANSI SQL join in Oracle.
    Bcoz of the problem we are getting less number of rows...........
    SO please please help me on this
    Regards
    Ashok

    Hi.
    I know this topic is here for a while now, but I had the same problem today, searched for help and didn´t find anything.
    Later I figured out how to do this.
    You just have to put the (+) one time, and the OWB converts in an LEFT OUTER JOIN statement.
    For this case, all you have to do is:
    ( INGRP1.branch_no = INGRP2.branch_no(+) AND INGRP1.item_no = INGRP2.item_no AND INGRP2.to_dt >= INGRP2.start_images )
    Regards,
    Godoy

  • Why is outer join more expensive than inner joins.

    Why is outer join more expensive than inner joins.
    Other than it may return more rows.
    If you know of any ORA docs on this, please let me know.
    Thanks.

    Outer join is inner join with outer union applied on top of it. As you correctly observed it returns more rows and that alone makes it more expensive. Secondly, outer join is not commutative. As a result some join permutations are exclused from consideration, which results in higher cost.

  • Left Outer Join with more than two tables in both CR 8.5 and XIR2

    I am trying to create a report and I have tried two versions of Crystal but I ultimately need the report in CR8.5 for compatibility with the client's system.  I think I am starting to figure out what might be wrong and it might be my understanding of SQL, but I can't see why someone hasn't needed this in the past. Ultimately I want to see all projects and any journal entry that might be posted for that project.
    Database is MySQL 5.0.38 and using MySQL ODBC driver 3.51.19.
    Project header table information will be populated. Each line item on a journal entry can be tagged with the project ID. But for me to pull the journal entry date I need also to link to a third table for the journal entry header info.
    I want to see all projects, whether a journal entry has been posted or not.
    So the links are like this
    ProjectHeader --->Left Outer Join ---> JELines ---> Inner Join ---> JEHeader
    I think in this scenerio Crystal is treating the LOJ as an IJ.
    I created two brand new reports today, one in CR8.5 and one in CR XIR2. Once I edited the automatic CR8.5 SQL statement (which I have been doing for years, usually without problem), they both ran properly. I linked customers to their invoices. Customers without invoices showed properly. But then I linked the invoices to the payments of the invoices and immediately lost customers without orders in both reports.
    So apparently only two tables are allowed in Outer Joins. Does this make sense?  I checked out the w3schools tutorial on SQL and it doesn't mention this limitation and I can't find anywhere else that it specifically indicates this but all samples of code I have seen only show two tables.  I just thought for presentation as a sample that was easiest to understand and we could expand as necessary.
    If this is correct, how does one go about accounting for this kind of thing?  One solution that goes through my mind is creating a view at the database level for the link between journal entry lines and journal entry headers.  Would this be a good solution under normal circumstances?
    A second option that I had to implement because of timelines, is to use a subreport linked to the main report through the project ID to pull the information for the journal entries and just pass the totals I need to the main report through a shared variable.
    These aren't normal circumstances because I don't have access to the database so I can't create the view.  I have come across this concept several times and I have been able to use subreports to solve it but I am trying to find a better solution for the future as sometimes subreports can be slow.  So are there any alternatives I have not considered here?
    TIA rasinc

    So after some more work and another post.  I was able to get this to work.
    Items disappear when linking to another table
    My issues were two fold.  I was selecting on the tables on the right-side of the original Inner Join.  However, I was checking for Nulls.  This apparently is correct but you must check for the Nulls first eg. (IsNull (JEHeader.Field1) OR JEHeader.Field1 <= 100).  I had my original statement reversed checking for <= 100 before checking for Nulls.
    I also did not set all links to be Left Outer Join.  I had the Inner Join.  I actually have about 6 tables in this report so all the links need to be set Outer Join.  So this now seems to be corrected.
    Thanks

  • Outer join on more than 2 tables

    I have difficulties joining more than 2 tables with Oracle 8.1.7. How can I solve this problem?
    SQL> select
    2 G.NOM_GARE, F.VOIE
    3 FROM FIN_POSTE F, TYPE_GARE G,
    4 ( SELECT MATRICULE, RED_CPT1 FROM REDDITION,
    5 ( SELECT SUM( PRIX_TOTAL ) CR, MATRICULE FROM TRANSACTION
    6 GROUP BY MATRICULE
    7 ) CASH_REV
    8 WHERE
    9 R.MATRICULE = CASH_REV.MATRICULE(+)
    10 ) R
    11 WHERE
    12 F.ID_GARE = G.ID_GARE(+)
    13 AND
    14 TRUNC( F.DATE_DEBUT_POSTE, 'MI' ) >= TO_DATE( '20030623 05:00', 'YYYYMMDD HH24:MI' )
    15 AND
    16 TRUNC( F.DATE_DEBUT_POSTE, 'MI' ) <= TO_DATE( '20030624 08:00', 'YYYYMMDD HH24:MI' )
    17 ORDER BY G.NOM_GARE,
    18 F.VOIE,
    19 F.MATRICULE,
    20 F.DATE_DEBUT_POSTE;
    R.MATRICULE = CASH_REV.MATRICULE(+)
    Hiba a(z) 9. sorban:
    ORA-00904: nem megengedett oszlopn�v

    It appears that you are using R as a alias for one of the in-line views when it should probably be aliasing the reddition table ?
    R is currently being referenced inside the in-line view for which it is an alias, which doesn't look right.

  • Translating SQL from MYSQL to ORACLE with more than one outer join.

    I will translate the following sqlquery from MYSQL to ORACLE:
    SELECT ticket.ticket_no,ticket.ticket_dato,ticket.ticket_subject,ticket.customer_id,customer_name,ticket.ticket_own_read, ticket.department_id, department.department_name, priority_name, tickstat_name, tickettype_name
    FROM customer, ticket left join department
    on ticket.department_id = department.department_id left join priority on ticket.priority_id = priority.priority_id
    left join ticketstatus on ticket.tickstat_id = ticketstatus.tickstat_id
    left join tickettype on ticket.tickettype_id = tickettype.tickettype_id
    where ticket.customer_id = customer.customer_id and customer.owner_id =
    #session.owner_id#
    I have tried in ORACLE with:
    SELECT ticket.ticket_no,ticket.ticket_dato,ticket.ticket_subject,ticket.customer_id,customer_name,ticket.ticket_own_read, ticket.department_id, department.department_name, priority_name, tickstat_name, tickettype_name
    FROM customer, ticket ,department, priority, ticketstatus, tickettype
    where
    ticket.department_id(+) = department.department_id and
    ticket.priority_id(+) = priority.priority_id and
    ticket.tickstat_id(+) = ticketstatus.tickstat_id and
    ticket.tickettype_id(+) = tickettype.tickettype_id and
    ticket.customer_id = customer.customer_id and customer.owner_id = #session.owner_id#
    I get an error:
    MERANT][ODBC Oracle driver][Oracle]ORA-01417: a table may be outer joined to at most one other table
    How do I translate the code to ORACLE?

    I think that your syntax is wrong. The (+) operator should be on the right hand table column, not the left hand table column if you want all rows on the left hand table column. If this syntax is really what you want, you can create underlying views for each join condiction.

  • How to specify more than Two Tables in NATURAL JOIN

    Hi,
    I am using Oracle9i R-2. I want help in writing a Query using Two Tables in SQL*PLUS. I am using ANSI/ISO Standrard for table-joins:
    select col1, col2, descr
    from tab1 natural join tab2
    There are two columns col1 & col2 is common between thse two tables. So, it will join them and query execute well.
    How can i use 3rd table tab3 in the same way in Natural Join...? If column col1 & col2 is available in tab3 also.
    I tried this way, but it gives me error:
    select col1, col2
    from tab1 natural join tab2 natural join tab3
    Is it possible to specify more than two tables in Natural Join Clause.
    Please check that out & help please. Thanks.
    Regards,
    Kamesh Rastogi

    I do not get an error when I try the same thing on the same version, as demonstrated below. Can you post your table structure and a copy and paste of a run of your actual query with the error that you are receiving?
    scott@ORA92> select banner from v$version
      2  /
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    PL/SQL Release 9.2.0.1.0 - Production
    CORE     9.2.0.1.0     Production
    TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
    NLSRTL Version 9.2.0.1.0 - Production
    scott@ORA92> select * from tab1
      2  /
          COL1       COL2 COL3
             1          1 A
            10         10 B
    scott@ORA92> select * from tab2
      2  /
          COL1       COL2 COL4
             1          1 C
            20         20 D
    scott@ORA92> select * from tab3
      2  /
          COL1       COL2 COL5
             1          1 E
            30         30 F
    scott@ORA92> select col1, col2, col3, col4, col5
      2  from tab1 natural join tab2 natural join tab3
      3  /
          COL1       COL2 COL3 COL4 COL5
             1          1 A    C    E
    scott@ORA92>

  • Outer join with first of zero or more rows

    Hi!
    I'm trying to make a join where one part is the first row of zero or more rows. I seem to be getting much poorer performance than I ought to be able to. My tables Node and RelayGroup have 6000 and 3000 rows respectively, while the CommandHist table has 10 million rows. Here are two queries that work, but are fairly slow:
    -- 37s, 28s, 27s
    SELECT DISTINCT n.NodeName,(SELECT Reason from commandhist where CommandHistId = (SELECT MAX(CommandHistID) FROM CommandHist WHERE NodeID = n.NodeID)) AS reason
    FROM RelayGroup rg
    JOIN Node n ON rg.NodeID = n.NodeID
    ORDER BY n.NodeName ASC ;
    -- 21s, 15s, 13s
    SELECT DISTINCT n.NodeName,(MAX(ch.Reason) KEEP (DENSE_RANK FIRST ORDER BY ch.CommandHistID DESC)) AS reason
    FROM RelayGroup rg
    JOIN Node n ON rg.NodeID = n.NodeID
    LEFT OUTER JOIN CommandHist ch ON ch.NodeID = rg.NodeID
    GROUP BY n.NodeName ORDER BY n.NodeName ASC ;
    I suspect that this could be made faster by using ROWNUM to get the first row from CommandHist -- what I'd like to do is
    SELECT n.NodeName, ch.CommandHistID
    FROM Node n
    JOIN RelayGroup rg ON n.NodeID = rg.NodeID
    LEFT OUTER JOIN (SELECT * FROM
    (SELECT CommandHistId, Reason, NodeID FROM CommandHist WHERE NodeID = n.NodeID ORDER BY CommandHistID)
    WHERE ROWNUM = 1) ch ON ch.NodeID = n.NodeID
    ORDER BY n.NodeName ASC;
    except n.NodeID cannot be used within the inner select. Is there a way to 'inject' the value of n.NodeID so that it can be seen from the inner select?
    Thanks in advance,
    -Lars

    Your requirement isn't exactly clear as you haven't provided any table information or example data for us to understand what you are talking about.
    If it's a performance issue take a look at these threads..
    [How to post a SQL tuning request|http://forums.oracle.com/forums/thread.jspa?threadID=863295&tstart=0]
    [When your query takes too long...|http://forums.oracle.com/forums/thread.jspa?messageID=1812597#1812597]

  • Joining more than just 2 tracks together

    Is it possible to connect more than just 2 tracks together from a cd? I would like to have a song that is continuous and i wanted it to be longer than just 2 track lengths...so i was just wondering before i wasted a cd and finding out it doesnt work!
    Thanks alot for all of your help!!!!

    Yes, just select all the songs you want to join and go Advanced>join cd tracks. They must be listed right next to each other though.
    bd

  • I am no musician, but have owned an iMac now for around four years. During that time I have had Garageband installed. I have dipped in and out very occasionally as I would like nothing more than to be able to get my head around it just for my own amusemen

    I am no musician, but have owned an iMac now for around four years. During that time I have had Garageband installed. I have dipped in and out very occasionally as I would like nothing more than to be able to get my head around it just for my own amusement really. I would at least like to be able to record my electric guitar with loops and tracks etc, just try to be a bit creative and see what comes out. The problem that I have is that perhaps its me, but every time I try to get to grips with this software, I just can't seem to get my head around it, even to begin to do something. I have now recently downloaded 10.0.2 which is confusing in itself, as, as far as I can ascertain that is actually version 11, but I'm not even sure about that. I have also recently purchased a Rocksmith RealTone Cable to connect my guitar. I can sometimes get a sound come out, but nothing to brilliant. And every time I try to set something up, it just doesn't seem to work out. I end up hitting buttons and controls in the simple hope that I may hit the correct control in order to get some sort of result. But I'm kind of fumbling in the dark with this. I have trawled the Internet just trying to find either a good manual or video tutorials for absolute beginners, but there just simply doesn't seem to be anything of that nature out there and what there is appears always to be very sketchy and not particularly detailed in explaining anything properly, and so I always find myself seemingly jumping in with both feet and just struggling to try and find a foothold with this on how to really begin. It is so frustrating as I can see the fantastic potential of this software, but just can't understand how to use it properly. If there is anyone out there who may be able to offer me some advice with this, I would be most grateful indeed... Many Thanks.

    I have now recently downloaded 10.0.2 which is confusing in itself, as, as far as I can ascertain that is actually version 11, but I'm not even sure about that.
    Version 10.0.2 is the newest version and the successor to GarageBand '11 (version 6.0.5).
    The '11 is referring to the iLife '11 suit of multimedia application - the older GarageBand was a part of this bundle.
    Have a look at Edgar's graphical enhanced manuals, the explain very detailed how things work and why. You can buy them as iBooks from the iBook store or directly from the page:
    http://DingDingMusic.com/Manuals/

  • HT6154 Can someone please just help me figure out how to update this stupid phone without losing anything? I somehow have more than one Apple ID on this,but I just want my music and my pictures to stay and I'm terrified of losing these things.

    Can someone please just help me figure out how to update this stupid phone(iPhone 4)without losing anything? I somehow have more than one Apple ID on this,but I just want my music and my pictures to stay and I'm terrified of losing these things. I have a lot of music from old CDs on here,and for some reason I can't even transfer them manually onto my computer. I'm not tech savvy whatsoever. Someone please help,having my music is the the whole reason I still have this phone.

    First read about back http://support.apple.com/kb/ht1766
    Then  read on how to transfer photos to your computer http://support.apple.com/kb/ts3195
    Then
    UPDATING iOS
    Over the air updating of iOS needs iOS 5 or later so unless you have iOS 5 or later you will not see updating in setting
    The following link explains how to update http://support.apple.com/kb/HT4972
    This link explains how to update using wireless http://support.apple.com/kb/HT4623
    This explains how to transfer purchases to your computer http://support.apple.com/kb/ht1848

  • How can i find out the more than one times occurance of integer in a array?

    How can i find out the more than one occurance of integer in a array. Assume i have 2,2,3,4,2,5,4,5 in a Array and i need to find out the how many times of 2, 5 and 4 is exists in that array. Please some one help me as sson as possible. thanks in advance....

    Kumar_Mohan wrote:
    How can i find out the more than one occurance of integer in a array. Assume i have 2,2,3,4,2,5,4,5 in a Array and i need to find out the how many times of 2, 5 and 4 is exists in that array. Sort the array. Then loop through it and compare each i-th element with the (i+1)-th element.
    Please some one help me as sson as possible. thanks in advance....In future postings, please refrain from telling that it is urgent, or you need help ASAP. It is rather rude to do so.

  • I have an HP Photosmart C4180 all in one printer scanner and copier, I can't figure out how to scan more than one page at a time and then send as a PDF file via email

    I have an HP Photosmart C4180 all-in-one, printer, scanner and copier.  I can't figure out how to scan more than one page?  It will only let me do one page at a time and then I have difficulty sending pages 1, 2 and 3 as one docuement.  Any ideas??
    Thank you, Jetteski

    Hello Jetteski,
    Hello Jetteski, Thanks for the post.
    Since you are running a MAC, check the below links for some excellent information on scanning.  Good Luck!
    http://goo.gl/M8Cl2
    http://goo.gl/cufK6
    http://goo.gl/OTQoR
    I work for HP but my posts and replies are my own....Thank you!

Maybe you are looking for

  • Installing from Tiger to Snow Leopard using only external monitor?

    Backstory: I currently have a mac book pro which i procured from a friend after he dropped it and broke the screen. He promptly went to the apple store and bought a new one and had them swap the hard drives. After hearing this I told him he could mos

  • I cant start Itunes..

    I cant start Itunes..."Error 7 (windows error 14001)" What I have to do?

  • Why has my broadband not been activated?

    Long painful story but suffice it to say I have been attempting to order broadband from BT for the last 5 months. On Friday 24th High Level Complaints informed me that they had FINALLY managed to place an order ...... lots of rubbish excuses about ro

  • Problem with backlight timer Off

    Hi! Just wanted to check if anybody had the same problem. I've recently updated my iPod with the latest Updater (software version 1.1). Since that time, when the backlight timer is set to Off,it is impossible to switch the light on with pressed Menu

  • How do I make them readable?

    How do I make what I uploaded readable..? @