Error in making left outer join to a nested query

i am writing this query getting error here i am using nested query with that i am making join it is giving error
SQL
SELECT
* FROM IVItem INNER JOIN
IVPackSize_Mst ON IVItem.PackSizeID = IVPackSize_Mst.Id
left outer join IvItemGenericLink on IvItemGenericLink.itemID=IVItem.Id
Select GenericId from
IvItemGenericLink where ItemID=IVItem.Id and rownum <=1
)x
and x on IvItemGenericLink.GenericId=x.GenericId;
Error report:
SQL Error: ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:   
*Action:
give me and suggestion

i am using left outer join at virtual table say x your gave me its equivalent
EXISTS (SELECT 1 FROM IvItemGenericLink G
WHERE G.ITEMID =V.ID
AND G.GenericId = L.GenericId)-----its i guess inner join
i am not confirmed that why iam asking this i guess i have to use this
as i use keyword inner join for inner join and for left join i use
left outer join
EXISTS (SELECT 1 FROM IvItemGenericLink G
WHERE G.ITEMID =V.ID
AND G.GenericId(+) = L.GenericId)-----its i guess left outer join
left outer join
Select GenericId from
IvItemGenericLink where ItemID=IVItem.Id and rownum <=1
)*x*
IvItemGenericLink.GenericId=x.GenericId
-------------------Statement U Gave in this--------------------------------------------------------------------------
SELECT *
FROM IVITEM V, IVPACKSIZE_MST M , IVITEMGENERICLINK L,
WHERE V.PACKSIZEID = M.ID
AND V.ID = L.ITEMID (+)
AND EXISTS (SELECT 1 FROM IvItemGenericLink G
WHERE G.ITEMID =V.ID
AND G.GenericId = L.GenericId)
-------------------Statement U Gave in this--------------------------------------------------------------------------
is this equivalent to left outer join
*AND EXISTS (
SELECT 1 FROM IvItemGenericLink G*
WHERE G.ITEMID =V.ID
*AND G.GenericId = L.GenericId
please tell me this in this regard

Similar Messages

  • Multiple left outer join in single select query

    My client requires to apply multiple left outer join in single select query.
    Tell me how it is possible . tell me if we can use native sql query.

    HI vineet,
    Using multile left join is possible but it reduce performance as it takes a long time to retrieve data.
    The following code would help you in knowing how to use multiple left join
    REPORT  test.
    PARAMETERS:
      p_auart LIKE vbak-auart.
    DATA:
      BEGIN OF fs_sales,
        auart LIKE vbak-auart,
        vbeln LIKE vbak-vbeln,
        posnr LIKE vbap-posnr,
        matnr LIKE vbap-matnr,
        netwr LIKE vbap-netwr,
      END OF fs_sales,
      fs_temp LIKE fs_sales.
    DATA:
      t_sales LIKE STANDARD TABLE OF fs_sales.
    SELECT k~auart
           k~vbeln
           p~posnr
           p~matnr
           p~netwr
      INTO TABLE t_sales
      FROM vbak AS k
      OUTER JOIN vbap AS p
      ON k~vbeln = p~vbeln
    WHERE auart = p_auart
       AND p~netwr LT 1000.
    IF sy-subrc EQ 0.
      WRITE:/5 'Sales Document'(001),/,
            15 'Sales Document Item'(002),
            40 'Material Number'(003).
      sort t_sales by netwr ascending.
      LOOP AT t_sales INTO fs_sales.
        WRITE:/ fs_sales-vbeln under text-001.
        LOOP AT t_sales INTO fs_temp WHERE vbeln = fs_sales-vbeln.
          WRITE:/ fs_temp-posnr under text-002,
                  fs_temp-matnr under text-003.
        ENDLOOP.
      ENDLOOP.
    ELSE.
      MESSAGE 'No Record Found' TYPE 'I'.
    ENDIF.
    But i would suggest you to go with views instead of using multiple joins..
    Best of luck,
    Bhumika

  • LEFT OUTER JOIN, Problem in POST-QUERY TRIGGER

    Hi,
    Please guide for the following
    I wrote below query in POST-QUERY Trigger of a TABULAR DATA BLOCK, having only one text item, called INVENTORY_ITEM
    select c.cat||' '||s.subcat||' '||l1.lvl1 ITEM INTO :DATABLOCK.INVENTORY_ITEM
    from itemcat c
    LEFT OUTER JOIN itemsubcat s on (c.catid = s.catid)
    LEFT OUTER JOIN lvl1 l1 on (s.subcatid = l1.subcatid)
    When I compile the module an error is generated
    *" Encountered the symbol 'LEFT' when expecting one of the following ,; for group having intersect minus order start union where connect ".*
    Above query is working fine in ORACLE SQL DEVELOPER .
    Any solution please.
    Regards,

    Difference

  • Query Of Queries : Error When Trying To Fake Left Outer Join

    Hi there
    I am trying to replicate a left outer join, combining two query of queries using a method I located here
    However, I keep getting an error message..
    Here is the code I am using....
        <cfquery dbtype="query" name="qry">
                    SELECT *
                    FROM returnQry, returnQry2
                    WHERE returnQry.mediumImage = returnQry2.mediumImage
                    ORDER BY returnQry.name   
                </cfquery>
                <cfquery name="returnQry3" dbtype="#application.mx#">
                    SELECT *
                    FROM trackmeanings AS t
                </cfquery>      
               <cfquery dbtype="query" name="endQry">
                    SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
                    FROM qry, returnQry3
                    WHERE qry.name = returnQry3.sNameTrack
                    UNION
                    SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
                    FROM qry, returnQry3
                    WHERE #qry.name# NOT IN (#QuotedValueList(returnQry3.sNameTrack)#)
                    GROUP BY name,nameRcd,mediumImage
                </cfquery>
    When I try to use the query output in a page, i get the error message "Incorrect conditional expression,  Expected one of [like|null|between|in|comparison] condition"
    Would anyone have any ideas?
    Many thanks

    Actually , spoke a little too soon, my query now seems to be outputting duplicates when the value is found on both sides of the union, my group by clause doesnt seem to be eliminating them like it usually does.
    My SELECT code now reads
    <cfquery dbtype="query" name="endQry">
    SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
    FROM qry, returnQry3
    WHERE qry.name = returnQry3.sNameTrack
    GROUP BY name,nameRcd,mediumImage
    UNION
    SELECT name,nameRcd,mediumImage, 0 AS comments
    FROM qry
    WHERE qry.name NOT IN (<cfqueryparam
    value="#returnQry3.sNameTrack#"
    cfsqltype="cf_sql_varchar"
    list="yes"
    />)
    GROUP BY name,nameRcd,mediumImage
    ORDER BY name DESC
    </cfquery>
    and my ouput...is producing duplicates
    <cfoutput query="rc.qryTopTracks" group="name">
    #rc.qryTopTracks.name#
    </cfoutput>
    Would you have any idea of how to eliminate them here?  Thanks

  • Problem with XMLTABLE and LEFT OUTER JOIN

    Hi all.
    I have one problem with XMLTABLE and LEFT OUTER JOIN, in 11g it returns correct result but in 10g it doesn't, it is trated as INNER JOIN.
    SELECT * FROM v$version;
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    "CORE     11.2.0.1.0     Production"
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    --test for 11g
    CREATE TABLE XML_TEST(
         ID NUMBER(2,0),
         XML XMLTYPE
    INSERT INTO XML_TEST
    VALUES
         1,
         XMLTYPE
              <msg>
                   <data>
                        <fields>
                             <id>g1</id>
                             <dat>data1</dat>
                        </fields>
                   </data>
              </msg>
    INSERT INTO XML_TEST
    VALUES
         2,
         XMLTYPE
              <msg>
                   <data>
                        <fields>
                             <id>g2</id>
                             <dat>data2</dat>
                        </fields>
                   </data>
              </msg>
    INSERT INTO XML_TEST
    VALUES
         3,
         XMLTYPE
              <msg>
                   <data>
                        <fields>
                             <id>g3</id>
                             <dat>data3</dat>
                        </fields>
                        <fields>
                             <id>g4</id>
                             <dat>data4</dat>
                        </fields>
                        <fields>
                             <dat>data5</dat>
                        </fields>
                   </data>
              </msg>
    SELECT
         t.id,
         x.dat,
         y.seqno,
         y.id_real
    FROM
         xml_test t,
         XMLTABLE
              '/msg/data/fields'
              passing t.xml
              columns
                   dat VARCHAR2(10) path 'dat',
                   id XMLTYPE path 'id'
         )x LEFT OUTER JOIN
         XMLTABLE
              'id'
              passing x.id
              columns
                   seqno FOR ORDINALITY,
                   id_real VARCHAR2(30) PATH '.'
         )y ON 1=1
    ID     DAT     SEQNO     ID_REAL
    1     data1     1     g1
    2     data2     1     g2
    3     data3     1     g3
    3     data4     1     g4
    3     data5          Here's everything fine, now the problem:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
    PL/SQL Release 10.2.0.1.0 - Production
    "CORE     10.2.0.1.0     Production"
    TNS for HPUX: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    --exactly the same environment as 11g (tables and rows)
    SELECT
         t.id,
         x.dat,
         y.seqno,
         y.id_real
    FROM
         xml_test t,
         XMLTABLE
              '/msg/data/fields'
              passing t.xml
              columns
                   dat VARCHAR2(10) path 'dat',
                   id XMLTYPE path 'id'
         )x LEFT OUTER JOIN
         XMLTABLE
              'id'
              passing x.id
              columns
                   seqno FOR ORDINALITY,
                   id_real VARCHAR2(30) PATH '.'
         )y ON 1=1
    ID     DAT     SEQNO     ID_REAL
    1     data1     1     g1
    2     data2     1     g2
    3     data3     1     g3
    3     data4     1     g4As you can see in 10g I don't have the last row, it seems that Oracle 10g doesn't recognize the LEFT OUTER JOIN.
    Is this a bug?, Metalink says that sometimes we can have an ORA-0600 but in this case there is no error returned, just incorrect results.
    Please help.
    Regards.

    Hi A_Non.
    Thanks a lot, I tried with this:
    SELECT
         t.id,
         x.dat,
         y.seqno,
         y.id_real
    FROM
         xml_test t,
         XMLTABLE
              '/msg/data/fields'
              passing t.xml
              columns
                   dat VARCHAR2(10) path 'dat',
                   id XMLTYPE path 'id'
         )x,
         XMLTABLE
              'id'
              passing x.id
              columns
                   seqno FOR ORDINALITY,
                   id_real VARCHAR2(30) PATH '.'
         )(+) y ;And is giving me the complete output.
    Thanks again.
    Regards.

  • Restriction to Left Outer Joins in PS Query

    Hello I am trying to do Left Outer JOin in PS QUERY. I need to do dept tbl, job code tbl and locatable as left outer joins with JOB Table. Looks like in PS QUERY there is a error message saying as below. Can someone has any workaround to achieve this in PS QUERY. I know I can create a View and use that in PS QUERY but BUsiness Users are dependent on IT, so that doesn't work. Also, adding JOB table multiple times works but I am looking for better solution if anyone had come accorss working through PS QUERY Outer JOins.
    Windows Internet Explorer
    Left outer joins must be joined to the last record in the query. (139,290)
    OK
    Thanks,
    SC.

    Hi Mike,
    According to your description, you want to improve the performance for your DAX query in SQL Server Analysis Service Tabular model, right? Here is a white paper describes strategies and specific techniques for getting the best performance from your tabular
    models, including processing and partitioning strategies, DAX query tuning, and server tuning for specific workloads.
    http://msdn.microsoft.com/en-us/library/dn393915.aspx
    Since this is a complex DAX query, from a support perspective this is really beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with Microsoft. Visit this link to see the various
    support options that are available to better meet your needs:
    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone
    Regards,
    Charlie Liao
    TechNet Community Support

  • Left outer join problem -- need feedback

    using crystal 2008
    haveing prolbems with a left outerjoin to get a blank field(null) to show up.
    basically i have some po line have have long descriptions or text fields that i want to include with the report. Below is my sql statement. I have written a formula with a join between 2 fields to get the report to work- this does but- it leave the polines off that do not have a long description.  I have tried left outer joins but seem to be having problems.  The long description field where the data is actually at is under my po.line table, although serveral area have long description fields -
    *one note i had to add a duplicate table to the field to get some items in my header to work properly - not sure if this is effecting the report or not.
    OK- when I set up the link to a LO join enforce from = to
    and dont add the ldtext.field to the report the left outjoin works(but no long description)and all my line items show up.
    1. when I keep the same join and add either just the ld.text field to  the report it comes back with a error saying invalid table
    2. when i use my formula that joins the ld.text and po.line and place it in the report with the same left outerjoin i get the same failure.
    3.  when i dont reference the ldtext(field) at all in the report it works fine w/ the lo join
    4. when i Dont use a left outer join and use my formula(see below)
    if not isnull(({LONGDESCRIPTION.LDTEXT }))
    then {POLINE.DESCRIPTION}+{LONGDESCRIPTION.LDTEXT}
    else {POLINE.DESCRIPTION}
    and link from poline.ld
    to ld.ldtext - my formula works and populates the po.line and the ld.text together - except that any po.line with no description will not show up. Like its not there.
    Not sure what to do?
    here is my current sql statement with the longdescription field in the select statement
    here is the error statement i am getting:
    Failed to retrieve data from the database:
    Details:42000[intersolv][odb sql base driver][sql base] 00906 itn invalid table name[database vendor code:906]
    sql statement:
    SELECT "PO"."PONUM", "PO"."STATUS", "PO"."VENDOR",
    "COMPANIES"."NAME", "COMPANIES"."ADDRESS1",
    "COMPANIES"."ADDRESS2", "COMPANIES"."ADDRESS3",
    "COMPANIES"."ADDRESS4", "COMPANIES"."PHONE",
    "COMPANIES"."FAX", "COMPANIES_1"."NAME",
    "COMPANIES_1"."ADDRESS1", "COMPANIES_1"."ADDRESS2",
    "COMPANIES_1"."ADDRESS3", "COMPANIES_1"."ADDRESS4",
    "COMPANIES_1"."CONTACT", "COMPANIES_1"."PHONE",
    "COMPANIES_1"."FAX", "PO"."PURCHASEAGENT",
    "PO"."ORDERDATE",
    "PO"."REQUIREDDATE", "PO"."PAYMENTTERMS",
    "PO"."SHIPVIA", "PO"."FREIGHTTERMS", "PO"."FOB",
    "POLINE"."DESCRIPTION", "POLINE"."ITEMNUM",
    "POLINE"."ORDERQTY", "POLINE"."UNITCOST",
    "POLINE"."LOADEDCOST", "POLINE"."POLINENUM",
    "PO"."SHIPTOATTN", "LONGDESCRIPTION"."LDTEXT"
    FROM   ("MAXIMO"."PO" "PO" LEFT OUTER JOIN
    "MAXIMO"."LONGDESCRIPTION" "LONGDESCRIPTION" ON "PO"."LDKEY"="LONGDESCRIPTION"."LDKEY"),
    "MAXIMO"."POLINE" "POLINE",
    "MAXIMO"."COMPANIES" "COMPANIES_1",
    "MAXIMO"."COMPANIES" "COMPANIES"
    WHERE  ("PO"."PONUM"="POLINE"."PONUM") AND ("PO"."VENDOR"="COMPANIES_1"."COMPANY") AND ("PO"."SHIPTO"="COMPANIES"."COMPANY") AND "PO"."PONUM"='3386-053'

    If you took the time to read this thanks.... turns out... and I just want to pull my hair out over this.  My connection had a  old odbc driver so somehow it would not allow a left outer join....go figure - weeks of agony over that..... thanks ....have to say love this forum.

  • Left outer join 3 tables with where-statement

    Hi folks,
    I hope you can understand (and maybe solve) my problem.
    Generally I try to left outer join three tables. The third table is used for a WHERE-statement.
    The three table structures are the following:
    table 1 (user)   
    user1 | key
    table 2 (detail)  
    key | ID
    table 3 (header)
    ID | user2                 
    ...and I want to achieve the following structure (as example filled with data):
    user | key | ID
    |-----|----
    xy    | a    | 001
    xy    | b    | #
    z     | b     | #
    The clue ist the usage of the third table. I need the table to set user1 and user2 equal (WHERE) but there are two problems:
    1) Obviously I can't left outer join two tables with each other. In this case I already used the 'key' of table 1 to join it with the 'key' of table 2. So I can't left outer join the 'ID' of table 2 with the 'ID' of table 3. Error message that I can only left outer join a table once. Any proposals?
    2) I have to include a WHERE to equal user1 with user2. But I am not allowed to use the user2 from table 3 because of the left outer join.
    I tried this coding:
    SELECT auser1 akey b~id INTO TABLE itab FROM ( table1 AS a
      LEFT OUTER JOIN table2 AS b ON akey = bkey )
      LEFT OUTER JOIN table3 AS c ON bID = cID )
      WHERE auser1 = cuser2.
    I would really appreciate your help.
    Regards
    MrclSpdl

    IF you want to join a DB table with an internal table, you need to use the 'FOR ALL ENTRIES' statement.
    select dbfields
    into table itab2
    from dbtab
    for all entries in itab
    where dbfield1 = itab-field1.
    This will get you a second internal table with all the corresponding data for the first selection.  You can then join them with a loop through the first table and a read table on the second table (for 1 - 1 relation) or a nested loop statement on both tables (for 1 - N relation).  Make itab a hashed table when using read table with key, use a sorted table if you need to loop without key access.
    Regards,
    Freek

  • Left Outer Join Help...

    Hi Everyone,
    I am still in the process of learning SQL, and I am having trouble specifically with the the left outer join.  I normally join tables using equijoin's, but I am not getting the right data set returns, and thought the using a left or right outer join would resolve the problem...
    Here is my SQL that is working properly with 1 left outer join.  I am building the query slowly so in the next SQL you will see where I am seeing the error.  I don't expect you to understand the data and columns I am trying to join, I believe the problems I am experiencing are related to syntax, and I am hoping you can find where my syntax errors are.
    select
      s.name as "Screen Name",
      sv.view_name as "View Name",
      s_view.name
    from
      s_screen s,
      s_screen_view sv
      left outer join s_view
      ON (sv.view_name = s_view.name)
    where
      sv.screen_id = '1-866A-1X3LU' and
      s.row_id = sv.screen_id and
      s.repository_id = '1-866A-1' and
      s_view.repository_id = '1-866A-1';
    Here is the SQL where I am experiencing the following error...
    Error:
    ORA-00904: "SV"."VIEW_NAME": invalid identifier
    00904. 00000 -  "%s: invalid identifier"
    *Cause:   
    *Action:
    Error at Line: 14 Column: 7
    Problematic SQL:
    select
      s.name as "Screen Name",
      sv.view_name as "View Name",
      s_view.name,
      s_applet.name as Applet
      --a.name as "Applet Name"
    from
      s_screen s,
      s_screen_view sv,
      s_view_wtmpl_it wti
      left outer join s_view
      ON (sv.view_name = s_view.name)
      left outer join s_applet
      ON (wti.name = s_applet.name)
    where
      sv.screen_id = '1-866A-1X3LU' and
      s.row_id = sv.screen_id and
      s.repository_id = '1-866A-1' and
      s_view.repository_id = '1-866A-1';
    Thanks in advance for your help.
    Chris

    Hi,
    cjpicc11 wrote:
    What is an Oracle style join vs. ANSI join?
    Would this be Oracle Style or ANSI Join?
      left outer join s_view
      ON (sv.view_name = s_view.name)
      left outer join s_applet
    Would this be Oracle Style or ANSI Join?
    s.row_id = sv.screen_id
    "Oracle style" or "old style" joins have commas between tables in the FROM clause, and the join conditions are all in the WHERE clause.  They do not use the keywords JOIN or ON.
    ANSI style joins have the keyword JOIN between tables (sometimes accompanied by other keywords, such as LEFT, OUTER or CROSS), and the join conditions are given in the FROM clause, usually after the keyword ON.
    The first example you gave is an ANSI style join.  It has the JOIN keyword, not a comma, between tables.
    The second example you gave:
    s.row_id = sv.screen_id
    could be part of either.  It could occur in an ANSI join (in the FROM clause, after the keyword ON), or it could occur in an old-style join (in the WHERE clause).

  • Ora-00904 left outer join

    Hi,
    I am trying to create a materialized view and trying replace + left outer join with 'left outer join' clause. I am getting
    ERROR at line 68:
    ORA-00904: "RF"."DATA_TYPE_ID": invalid identifier
    Here is the sql I am using. Any help is appreciated.
    CREATE MATERIALIZED VIEW HHC_CUSTOM.HHC_RESULT_FIELD_DIMENSION0925 (DATA_ELEMENT_ID,FIELD,PROFILE,PROFILE_ID,PARENT_FIELD,PARENT_PROFILE,PARENT_PROFILE_ID,DATA_TYPE,DECODE_TYPE,CFG_GROUP,CFG_SET,ACTIVITY_COUNT)
    TABLESPACE CUSTOM_01
    PCTUSED 0
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 80K
    NEXT 1M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    FLASH_CACHE DEFAULT
    CELL_FLASH_CACHE DEFAULT
    NOCACHE
    ENABLE ROW MOVEMENT
    NOLOGGING
    NOCOMPRESS
    NOPARALLEL
    BUILD IMMEDIATE
    REFRESH COMPLETE on DEMand
    WITH PRIMARY KEY
    AS
    /* Formatted on 9/25/2012 11:53:36 AM (QP5 v5.215.12089.38647) */
    SELECT /*+ ALL_ROWS FULL(rf) FULL(dt) FULL(dc) FULL(rd) FULL(mc) FULL(ad) FULL(ag) USE_HASH(rf,dt,dc,rd,mc,ad,ag) INDEX(prf,KP_RESULT_FIELD) INDEX(prd,KP_RESULT_PROFILE) INDEX(pmc,KP_RESULT_MULTI_FIELD_PROFILE) INDEX(pad,KP_ASSESS_PROFILE) INDEX(pag,KP_ASSESS_MULTI_FIELD_PROFILE) USE_NL(prf,prd,pmc,pad,pag) ORDERED(rf,dt,dc,rd,mc,ad,ag,prf,prd,pmc,pad,pag) */
    rf.data_element_id AS data_element_id,
    rf.name AS field,
    DECODE (SUBSTR (rf.data_element_id, 1, 3),
    'RD/', rd.name,
    'AG/', ag.name,
    'AD/', ad.name,
    'MC/', mc.name)
    AS profile,
    DECODE (SUBSTR (rf.data_element_id, 1, 3),
    'RD/', rd.profile_id,
    'AG/', ag.profile_id,
    'AD/', ad.profile_id,
    'MC/', mc.profile_id)
    AS profile_id,
    prf.name AS parent_field,
    DECODE (SUBSTR (rf.parent_profile_field_id, 1, 3),
    NULL, NULL,
    'RD/', prd.name,
    'AD/', pad.name,
    'AG/', pag.NAME, --shouldn't happen
    'MC/', pmc.name --shouldn't happen
    AS parent_profile,
    DECODE (SUBSTR (rf.parent_profile_field_id, 1, 3),
    NULL, NULL,
    'RD/', prd.profile_id,
    'AD/', pad.profile_id,
    'AG/', pag.profile_id, --shouldn't happen
    'MC/', pmc.profile_id --shouldn't happen
    AS parent_profile_id,
    dt.name AS data_type,
    NVL (dc.name,
    DECODE (UPPER (dt.name), 'ORGANISM', 'Organism', 'Not Coded'))
    AS decode_type,
    NVL (cfg.cfg_group, 'UNDEFINED') AS cfg_group,
    NVL (cfg.cfg_set, 'UNDEFINED') AS cfg_set,
    DECODE (rslt.data_element_id, NULL, 0, rslt.activity_count)
    AS activity_count
    FROM ud_master.result_field rf,ud_master.result_field prf
    join ud_master.data_type dt on (rf.data_type_id=dt.data_type_id)
    left outer join ud_master.decode_type dc on (rf.decode_source_id = dc.decode_source_id)
    left outer join ud_master.result_profile rd on (rf.profile_id = rd.profile_id)
    left outer join ud_master.result_multi_field_profile mc on (rf.profile_id = mc.profile_id)
    left outer join ud_master.assess_profile ad on (rf.profile_id = ad.profile_id)
    left outer join ud_master.assess_multi_field_profile ag on (rf.profile_id = ag.profile_id)
    left outer join ud_master.result_field rf on (prf.parent_profile_field_id = rf.data_element_id)
    left outer join ud_master.result_profile prd on (prf.profile_id = prd.profile_id)
    left outer join ud_master.result_multi_field_profile pmc on (prf.profile_id = pmc.profile_id)
    left outer join ud_master.assess_profile pad on (prf.profile_id = pad.profile_id)
    left outer join ud_master.assess_multi_field_profile pag on (rf.profile_id = pag.profile_id)
    left outer join (SELECT * FROM hhc_custom.dw_cfg_v WHERE cfg_type_id = 1) cfg on (rf.data_element_id = cfg.cfg_value)
    left outer join (SELECT data_element_id, COUNT (*) AS activity_count FROM ud_master.result GROUP BY data_element_id) rslt on (rf.data_element_id = rslt.data_element_id);
    Regards,
    Kotesh

    Hi Monica,
    I need to have 2 aliases for ud_master.result_field table
    So I f I change it like this
    CREATE MATERIALIZED VIEW HHC_CUSTOM.HHC_RESULT_FIELD_DIMENSION0925 (DATA_ELEMENT_ID,FIELD,PROFILE,PROFILE_ID,PARENT_FIELD,PARENT_PROFILE,PARENT_PROFILE_ID,DATA_TYPE,DECODE_TYPE,CFG_GROUP,CFG_SET,ACTIVITY_COUNT)
    TABLESPACE CUSTOM_01
    PCTUSED 0
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 80K
    NEXT 1M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    FLASH_CACHE DEFAULT
    CELL_FLASH_CACHE DEFAULT
    NOCACHE
    ENABLE ROW MOVEMENT
    NOLOGGING
    NOCOMPRESS
    NOPARALLEL
    BUILD IMMEDIATE
    REFRESH COMPLETE on DEMand
    WITH PRIMARY KEY
    AS
    /* Formatted on 9/25/2012 11:53:36 AM (QP5 v5.215.12089.38647) */
    SELECT /*+ ALL_ROWS FULL(rf) FULL(dt) FULL(dc) FULL(rd) FULL(mc) FULL(ad) FULL(ag) USE_HASH(rf,dt,dc,rd,mc,ad,ag) INDEX(prf,KP_RESULT_FIELD) INDEX(prd,KP_RESULT_PROFILE) INDEX(pmc,KP_RESULT_MULTI_FIELD_PROFILE) INDEX(pad,KP_ASSESS_PROFILE) INDEX(pag,KP_ASSESS_MULTI_FIELD_PROFILE) USE_NL(prf,prd,pmc,pad,pag) ORDERED(rf,dt,dc,rd,mc,ad,ag,prf,prd,pmc,pad,pag) */
    rf.data_element_id AS data_element_id,
    rf.name AS field,
    DECODE (SUBSTR (rf.data_element_id, 1, 3),
    'RD/', rd.name,
    'AG/', ag.name,
    'AD/', ad.name,
    'MC/', mc.name)
    AS profile,
    DECODE (SUBSTR (rf.data_element_id, 1, 3),
    'RD/', rd.profile_id,
    'AG/', ag.profile_id,
    'AD/', ad.profile_id,
    'MC/', mc.profile_id)
    AS profile_id,
    prf.name AS parent_field,
    DECODE (SUBSTR (rf.parent_profile_field_id, 1, 3),
    NULL, NULL,
    'RD/', prd.name,
    'AD/', pad.name,
    'AG/', pag.NAME, --shouldn't happen
    'MC/', pmc.name --shouldn't happen
    AS parent_profile,
    DECODE (SUBSTR (rf.parent_profile_field_id, 1, 3),
    NULL, NULL,
    'RD/', prd.profile_id,
    'AD/', pad.profile_id,
    'AG/', pag.profile_id, --shouldn't happen
    'MC/', pmc.profile_id --shouldn't happen
    AS parent_profile_id,
    dt.name AS data_type,
    NVL (dc.name,
    DECODE (UPPER (dt.name), 'ORGANISM', 'Organism', 'Not Coded'))
    AS decode_type,
    NVL (cfg.cfg_group, 'UNDEFINED') AS cfg_group,
    NVL (cfg.cfg_set, 'UNDEFINED') AS cfg_set,
    DECODE (rslt.data_element_id, NULL, 0, rslt.activity_count)
    AS activity_count
    FROM ud_master.result_field rf,ud_master.result_field prf
    join ud_master.data_type dt on (prf.data_type_id=dt.data_type_id)
    left outer join ud_master.decode_type dc on (prf.decode_source_id = dc.decode_source_id)
    left outer join ud_master.result_profile rd on (prf.profile_id = rd.profile_id)
    left outer join ud_master.result_multi_field_profile mc on (prf.profile_id = mc.profile_id)
    left outer join ud_master.assess_profile ad on (prf.profile_id = ad.profile_id)
    left outer join ud_master.assess_multi_field_profile ag on (prf.profile_id = ag.profile_id)
    left outer join ud_master.result_field rf on (prf.parent_profile_field_id = rf.data_element_id)
    left outer join ud_master.result_profile prd on (prf.profile_id = prd.profile_id)
    left outer join ud_master.result_multi_field_profile pmc on (prf.profile_id = pmc.profile_id)
    left outer join ud_master.assess_profile pad on (prf.profile_id = pad.profile_id)
    left outer join ud_master.assess_multi_field_profile pag on (rf.profile_id = pag.profile_id)
    left outer join (SELECT * FROM hhc_custom.dw_cfg_v WHERE cfg_type_id = 1) cfg on (rf.data_element_id = cfg.cfg_value)
    left outer join (SELECT data_element_id, COUNT (*) AS activity_count FROM ud_master.result GROUP BY data_element_id) rslt on (rf.data_element_id = rslt.data_element_id);
    I am getting the following error
    DECODE (SUBSTR (rf.parent_profile_field_id, 1, 3),
    ERROR at line 51:
    ORA-00918: column ambiguously defined
    Following is the original query I tried to modify
    CREATE MATERIALIZED VIEW HHC_CUSTOM.HHC_RESULT_FIELD_DIMENSION (DATA_ELEMENT_ID,FIELD,PROFILE,PROFILE_ID,PARENT_FIELD,PARENT_PROFILE,PARENT_PROFILE_ID,DATA_TYPE,DECODE_TYPE,CFG_GROUP,CFG_SET,ACTIVITY_COUNT)
    TABLESPACE CUSTOM_01
    PCTUSED 0
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 80K
    NEXT 1M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    FLASH_CACHE DEFAULT
    CELL_FLASH_CACHE DEFAULT
    NOCACHE
    ENABLE ROW MOVEMENT
    NOLOGGING
    NOCOMPRESS
    NOPARALLEL
    BUILD IMMEDIATE
    REFRESH COMPLETE ON DEMAND
    WITH PRIMARY KEY
    AS
    /* Formatted on 9/26/2012 1:59:27 PM (QP5 v5.215.12089.38647) */
    SELECT /*+ ALL_ROWS FULL(rf) FULL(dt) FULL(dc) FULL(rd) FULL(mc) FULL(ad) FULL(ag) USE_HASH(rf,dt,dc,rd,mc,ad,ag) INDEX(prf,KP_RESULT_FIELD) INDEX(prd,KP_RESULT_PROFILE) INDEX(pmc,KP_RESULT_MULTI_FIELD_PROFILE) INDEX(pad,KP_ASSESS_PROFILE) INDEX(pag,KP_ASSESS_MULTI_FIELD_PROFILE) USE_NL(prf,prd,pmc,pad,pag) ORDERED(rf,dt,dc,rd,mc,ad,ag,prf,prd,pmc,pad,pag) */
    rf.data_element_id AS data_element_id,
    rf.name AS field,
    DECODE (SUBSTR (rf.data_element_id, 1, 3),
    'RD/', rd.name,
    'AG/', ag.name,
    'AD/', ad.name,
    'MC/', mc.name)
    AS profile,
    DECODE (SUBSTR (rf.data_element_id, 1, 3),
    'RD/', rd.profile_id,
    'AG/', ag.profile_id,
    'AD/', ad.profile_id,
    'MC/', mc.profile_id)
    AS profile_id,
    prf.name AS parent_field,
    DECODE (SUBSTR (rf.parent_profile_field_id, 1, 3),
    NULL, NULL,
    'RD/', prd.name,
    'AD/', pad.name,
    'AG/', pag.NAME, --shouldn't happen
    'MC/', pmc.name --shouldn't happen
    AS parent_profile,
    DECODE (SUBSTR (rf.parent_profile_field_id, 1, 3),
    NULL, NULL,
    'RD/', prd.profile_id,
    'AD/', pad.profile_id,
    'AG/', pag.profile_id, --shouldn't happen
    'MC/', pmc.profile_id --shouldn't happen
    AS parent_profile_id,
    dt.name AS data_type,
    NVL (dc.name,
    DECODE (UPPER (dt.name), 'ORGANISM', 'Organism', 'Not Coded'))
    AS decode_type,
    NVL (cfg.cfg_group, 'UNDEFINED') AS cfg_group,
    NVL (cfg.cfg_set, 'UNDEFINED') AS cfg_set,
    DECODE (rslt.data_element_id, NULL, 0, rslt.activity_count)
    AS activity_count
    FROM ud_master.result_field rf,
    ud_master.data_type dt,
    ud_master.decode_type dc,
    ud_master.result_profile rd,
    ud_master.result_multi_field_profile mc,
    ud_master.assess_profile ad,
    ud_master.assess_multi_field_profile ag,
    ud_master.result_field prf,
    ud_master.result_profile prd,
    ud_master.result_multi_field_profile pmc,
    ud_master.assess_profile pad,
    ud_master.assess_multi_field_profile pag,
    (SELECT *
    FROM hhc_custom.dw_cfg_v
    WHERE cfg_type_id = 1) cfg,
    ( SELECT data_element_id, COUNT (*) AS activity_count
    FROM ud_master.result
    GROUP BY data_element_id) rslt
    WHERE rf.data_type_id = dt.data_type_id
    AND rf.decode_source_id = dc.decode_source_id(+)
    AND rf.profile_id = rd.profile_id(+)
    AND rf.profile_id = mc.profile_id(+)
    AND rf.profile_id = ad.profile_id(+)
    AND rf.profile_id = ag.profile_id(+)
    AND rf.parent_profile_field_id = prf.data_element_id(+)
    AND prf.profile_id = prd.profile_id(+)
    AND prf.profile_id = pmc.profile_id(+)
    AND prf.profile_id = pad.profile_id(+)
    AND prf.profile_id = pag.profile_id(+)
    AND rf.data_element_id = cfg.cfg_value(+)
    AND rf.data_element_id = rslt.data_element_id(+);
    Can you tell me how can I rewrite it with 'LEFT OUTER JOIN' syntax?
    Regards,
    Kotesh

  • Left outer join on Fact and dimension table.

    Hi all, I have a fact F with account number and few measures as columns.
    I also have a dimension D with account number, account name columns.
    Few account numbers from Fact doesnt exist in Dimension D , but they need to show up in the report though.
    How do I left join Fact and Dimension D in RPD?
    I have this report where I need to show Account Number, Account name, measures.
    If D doesnt have certain account numbers, I need to convert that account number from F as string and show it in the report in account name column.
    Can you pls help.

    Ok. I tried this:
    Driving table : Fact, Left outer join -- didnt work.
    Driving table: Dimension D left outer join -- didnt work either
    In either the case, I see physical query as D left outer Join on Fact F. and omitting the rows.
    And then I tried this -
    Driving table: Fact, RIght outer join.
    Now, this is giving me error:
    Sybase][ODBC Driver]Internal Error. [nQSError: 16001] ODBC error state: 00000 code: 30128 message: [Sybase][ODBC Driver]Data overflow. Increase specified column size or buffer size. [nQSError: 16011] ODBC error occurred while executing SQLExtendedFetch to retrieve the results of a SQL statement. (HY000)
    I checked all columns, everything matched with database table type and size.
    I am pulling Fact.account number, Dimension.account name, Fact.Measures. I am seeing this error each time I pull Fact.Account number.

  • Left Outer Joining multiple tables to one source table FAILS with VLD-1511

    Hi all,
    Is it me, or is OWB unable to handle left outer joining 1 source table to multiple other tables?
    I want to load a fact table so I have 1 source table with measures. This table must be outer joined to some dimensions that have their FK in the fact table.
    The SQL statement would look like this (and is perfectly valid):
    select ...
    from input, dim1, dim2
    where input.c1 = dim1.c1(+)
    and input.c2 = dim2.c2(+);
    I put the where clause in the joiner operator and validate, but that gives me message VLD-1511: A table may be outer joined to at most one other table.
    Even splitting this up into one outer join per joiner still gives this message.
    A search and look around on the forum and on metalink shows there are related issues (like bug 3334035). Seemingly creating a view is the work-around to use.....? (ie downgrading owb to a simple gui tool) }-;
    Have other people experienced this problem of not being able to outer join one input table to multiple other tables?
    Thanks,
    Ed

    I have had some feedback from Oracle. It turns out this has to do with 2 issues. Below I have pasted the text that Support gave me:
    <---------- START QUOTE ---------->
    RESEARCH
    =========
    Bug 3437036 KEY LOOKUP DOES NOT DETECT ORA-1417 IN VALIDATE/GENERATE STEP
    Unpublished Bug 4211684 FORWARD PORT OF BUG 3437036
    shows:
    Some more development has been completed when this bug is fixed in Paris.
    The following are the details:
    1. If the join condition contains a full outer join such as
    tab1.c (+) = tab2.c (+) and tab2.c (+) = tab3.c
    then the new validations implemented for this bug do not apply since
    in OWB, full outer join triggers generation of joins in ANSI syntax.
    ANSI syntax does not have the original problem the base bug of this
    bug reported.
    2. If the join condition does not contain any full outer join condition,
    then the join is generated in Oracle join syntax, which is subject two
    several restrictions. The fix to this bug check two of the restrictions.
    3. The first restriction in Oracle syntax is that the outer join operator
    "(+)" can only directly be attached to a column name. If you attach it
    to an expression, such as the following:
    (tab1.c + 1) (+) = tab2.c
    Then there will be an ORA-936 error at the time of mapping deployment.
    For this case, I have added a validation message VLD-1512 to error out
    this situation.
    4. The second restriction in Oracle syntax is that a table can only be
    outer joined to exactly one other table.
    For example, this is an invalid join in Oracle syntax:
    tab1.c (+) = tab2.c and tab1.d (+) = tab3.d
    because tab1 is left outer joined to tab2 and tab3.
    But note that the following is still valid in Oracle syntax:
    tab1.c (+) = tab2.c and tab1.d = tab3.d (+)
    because tab1 is left outer joined to tab2 and right outer joined to tab3.
    So this latter case does not violate the restriction that "same oj" to
    more than 1 table is not allowed.
    If same oj to more than 1 table is specified in a join condition,
    VLD-1511 will be issued, and the map is made invalid.
    <---------- END QUOTE ---------->
    OWB does a partial validation, ie not all access paths are (can be) checked. A full check is only done by the database itself. So some scenarios (like checking whether multiple tables are outer joined the correct way) are not checked, and in this case are flagged with an error (even though it is actually a correct scenario).
    Seemingly this was not flagged with an error in earlier versions of OWB, so beware, OWB behaviour may change when upgrading...
    Alternative solutions are (1) using key lookups, (2) using a view with all outer joins in there, (3) using intermediate result tables between the joins.
    Hope this info helps some people prevent spending too much time on a false error message,
    Ed

  • LEFT OUTER JOIN SQL syntax

    Haven't seen a solution to this on the forum or in the docs. My last post timed out with no responses, but I still don't know if I have a possible solution.
    I've got 2 objects, Task and Role, that are linked in a M-M relationship.
    My tables are:
    T_TASKS
    T_TASKSROLES
    T_ROLES
    I am querying T_TASKS and joining on T_TASKSROLES and T_ROLES, but I need to use an outer join because not all Tasks have a Role in T_TASKSROLES.
    In SQL Server, my FROM clause SHOULD look like this:
    FROM (T_TASKSROLES t2 LEFT OUTER JOIN T_TASKS t1 ON t1.ID = t2.TASKID) LEFT OUTER JOIN T_ROLES t0 ON t0.ID = t2.ROLEID
    however, if I use eb.anyOfAllowingNone(_roles) in my ExpressionBuilder. TopLink creates a LEFT OUTER JOIN clause that looks like this:
    FROM T_ROLES t0 LEFT OUTER JOIN T_TASKS t1 ON((t0.ID = T_TASKSROLES.ROLEID) AND (t1.ID = T_TASKSROLES.TASKID))
    I can see the logic in how it builds this clause. But, it doesn't parse in SQL Server.
    Is there a way to effect how TopLink generates the FROM clause for outer joins? I mean, I understand how to use the XXXPlatform.java source files and can change whether to use OuterJoin in the WHERE clause or not. But, I can't see anything in the platform class that would allow me to figure this out.
    I realize I could write SQL manually, but is there a way to do this so that the same code would work on SQL Server, Oracle, and Sybase (assuming the DatabaseLogin is configured appropriately)?
    It just seems like LEFT OUTER JOIN when joining M-M relationships isn't generating proper SQL. Is the TopLink SQL SQL92-compliant?
    I should add that I have tried to change SQLServerPlatform to have shouldPrintOuterJoinInWhereClause() return "true". This embeds a "=*" in the join conditions in the WHERE clause.
    SQL Server 2000 still supports this syntax, but the "=*" isn't ALWAYS the correct operator. It is important to put the "*" on the correct side of the expression. TopLink always prints "=*", but the operators are not always in the correct order. So, it tries to create a "left join" on the wrong table.
    So my other question, is it possible to force TopLink to remember to put the outer join table in the RIGHT SIDE?
    Nate

    The workaround is actually more complicated than that, and it can't be fixed by changing only the operator.
    In the queries you listed, the only difference is which side of the "AND" the expressions appear on.
    Change "(t2.rightid (+)= t1.rightid)" to "(t1.rightid (+)= t2.rightid)" and I'm guessing (although not sure because I am testing with SQL Server at the moment), that you'll get a similar query error as I did.
    The bug here is that the default M-M selection criteria creates "reltable = table1 AND table2 = reltable". There is no operator that can satisfy this expression.
    So, the fix that I made, for all of my M-M Mappings was to set the SelectionCriteria manually using the following Expression (returned from this method):
    // This puts M-M relationship tables on the same side of expressions so that OUTER JOINS can be supported.
    private Expression getSameSideExpression() {
              // target side
              Expression selectionCriteria = null;
    Enumeration e2 = getTargetKeyFields().elements();
    Enumeration e = getTargetRelationKeyFields().elements();
    ExpressionBuilder eb = new ExpressionBuilder();
    Expression relTableExp = null;
    while(e2.hasMoreElements()) {
    DatabaseField df = (DatabaseField) e.nextElement();
    DatabaseField df2 = (DatabaseField) e2.nextElement();
    if(relTableExp == null){
    relTableExp = eb.getTable(df.getTable());
    Expression targetFieldExp = eb.getField(df2);
    Expression relFieldExp = relTableExp.getField(df);
    Expression joinExp = relFieldExp.equal(targetFieldExp);
    if(selectionCriteria == null)
    selectionCriteria = joinExp;
    else
    selectionCriteria = joinExp.and(selectionCriteria);
              // source side
    e = getSourceRelationKeyFields().elements();
              e2 = getSourceKeyFields().elements();
    while(e.hasMoreElements()) {
    DatabaseField df = (DatabaseField) e.nextElement();
    DatabaseField df2 = (DatabaseField) e2.nextElement();
    Expression relFieldExp = relTableExp.getField(df);
    Expression sourceFieldExp = eb.getParameter(df2);
    Expression joinExp = relFieldExp.equal(sourceFieldExp);
    if(selectionCriteria == null)
                        selectionCriteria = joinExp;
    else
    selectionCriteria = joinExp.and(selectionCriteria);
              return selectionCriteria;
    This changes the M-M Selection Criteria to "table1 = reltable AND table2 = reltable". Now that this is consistent, using the WHERE clause for my joins in SQL Server is possible.
    If you can think of any other problems this change may have, please let me know.
    Thanks for the help.
    Nate

  • Sql help (left outer join)

    Hi All,
    I am referring 2 regular tables from the HR schema which you get when you install Oracle 9i , Now the issue is that I want all the rows from my employees table even if the row doesnt have the salary equal to 2500.
    Here is my Sql:
    select e.employee_id
         , e.first_name
         , e.last_name
         , e.salary
         , e.department_id e_dep_id
         , d.department_id d_dep_id
         , d.department_name
         , d.location_id
    from employees e
    , departments d
    where 1 = 1
         And e.department_id = d.department_id(+) And e.SALARY = 2500
    I am achieving my result set from the below query though(its just a syntactical problem) , please help :
    select e.employee_id
         , e.first_name
         , e.last_name
         , e.salary
         , e.department_id e_dep_id
         , d.department_id d_dep_id
         , d.department_name
         , d.location_id
    from employees e left outer join
    departments d
    on e.department_id = d.department_id And e.SALARY = 2500
    Regards
    Rahul

    Mac_Freak_Rahul wrote:
    Well my requirement is to pull all the records from my driving table(ie employees) doesnt matter weather the condition satisfies or not. Just to add to that lets say I would need to bring another table and my join criteria involves data from the employees table and the third table(in this case I need to make sure that all the rows from my driving table remains and doesnt get filter out). Please help my only problem is of the new syntax of outer joins.
    Regards
    RahulRahul,
    Why do you want to use "oracle only syntax ( + )"? I highly recommend you to use ANSI syntax, it's much more readable:
    This is from Oracle's documents:
    Oracle recommends that you use the FROM clause OUTER JOIN syntax rather than the Oracle join operator. Outer join queries that use the Oracle join operator (+) are subject to the following > rules and restrictions, which do not apply to the FROM clause OUTER JOIN syntax:
    You cannot specify the (+) operator in a query block that also contains FROM clause join syntax.
    The (+) operator can appear only in the WHERE clause or, in the context of left-correlation (that is, when specifying the TABLE clause) in the FROM clause, and can be applied only to a column > of a table or view.
    If A and B are joined by multiple join conditions, then you must use the (+) operator in all of these conditions. If you do not, then Oracle Database will return only the rows resulting from a > simple join, but without a warning or error to advise you that you do not have the results of an outer join.
    The (+) operator does not produce an outer join if you specify one table in the outer query and the other table in an inner query.
    You cannot use the (+) operator to outer-join a table to itself, although self joins are valid. For example, the following statement is not valid:
    -- The following statement is not valid:
    SELECT employee_id, manager_id
    FROM employees
    WHERE employees.manager_id(+) = employees.employee_id;
    However, the following self join is valid:
    SELECT e1.employee_id, e1.manager_id, e2.employee_id
    FROM employees e1, employees e2
    WHERE e1.manager_id(+) = e2.employee_id;
    The (+) operator can be applied only to a column, not to an arbitrary expression. However, an arbitrary expression can contain one or more columns marked with the (+) operator.
    A WHERE condition containing the (+) operator cannot be combined with another condition using the OR logical operator.
    A WHERE condition cannot use the IN comparison condition to compare a column marked with the (+) operator with an expression.
    A WHERE condition cannot compare any column marked with the (+) operator with a subquery.Best Regards,
    Gokhan
    If this question is answered, please mark appropriate posts as correct/helpful and the thread as closed. Thanks

  • Trouble With Left Outer Join

    I'm kind of new to using left outer joins, so I don't know if I'm doing it quite right. Right now there's only one table that may or may not have a corresponding record, so I'm only using left outer join on it. I get the error ORA-00904: "A"."SGBSTDN_PIDM": invalid identifier right now when I try to run my query. This gives me the impression that I need to use left outer join on all the tables in my FROM clause. Any suggestions on what I need to do?
    /*Get those students not awarded ACG1 yet with an entry in shrlgpa*/
    SELECT spriden_id id, spriden_last_name||', '||spriden_first_name name, sgbstdn_styp_code student_type,
    sorhsch_graduation_date hsch_grad_date,shrlgpa_hours_earned hours_earned,rorenrl_finaid_adj_hr hours_enrolled,
    0 AS disbursement_to_date, 0 AS offer_amt, 0 AS current_disbursement,
    rnvand0_unmet_need unmet_need, 'N' AS awarded
    FROM RCRESAR,RCRAPP1,SORHSCH,RORHSDT,SGBSTDN A,SORLCUR, shrlgpa, rorstat, ROBINST, spriden
    ,rnvand0
    LEFT OUTER JOIN rorenrl ON (A.sgbstdn_pidm = rorenrl_pidm)
    WHERE (RCRESAR_PELL_ELGBL = 'Y')
        AND  SORHSCH_GRADUATION_DATE>'01-JAN-2006'
        AND  RCRAPP1_CITZ_IND IN ('1','2')
        AND  RCRAPP1_CURR_REC_IND='Y'
        /*Possible change once rigorous curr. decided AND (RORHSDT_AP_IB_COURSES = 'Y' OR RORHSDT_REQ_COURSES='Y')*/
        AND RORHSDT_REQ_COURSES='Y'
        AND sgbstdn_stst_code = 'AS'
        AND  SGBSTDN_STYP_CODE IN ('F','H','T')
        AND (SORLCUR_DEGC_CODE LIKE 'B%' OR SORLCUR_DEGC_CODE LIKE 'A%'
        OR SORLCUR_DEGC_CODE = 'UND')
        AND sorlcur_seqno = (SELECT MAX(sorlcur_seqno)
                              FROM sorlcur
                              WHERE sorlcur_pidm = A.sgbstdn_pidm
                              AND sorlcur_term_code = &enrollment_term)
        AND  SORLCUR_CACT_CODE='ACTIVE' 
        AND rorenrl_term_code = &enrollment_term
        AND shrlgpa_hours_earned BETWEEN 0 AND 29
        AND shrlgpa_gpa_type_ind = 'O'
        AND rorstat_pckg_comp_date IS NOT NULL
        AND  A.SGBSTDN_TERM_CODE_EFF = (SELECT MAX(B.SGBSTDN_TERM_CODE_EFF)
                                                                            FROM SGBSTDN B
                                                                             WHERE B.SGBSTDN_PIDM = A.SGBSTDN_PIDM
                                                                             AND sgbstdn_term_code_eff <= &enrollment_term
        AND NOT EXISTS (SELECT 'X'
                                        FROM RPRAWRD
                                      WHERE RCRESAR_PIDM = RPRAWRD_PIDM
                                          AND RCRESAR_AIDY_CODE = RPRAWRD_AIDY_CODE
                                          AND RPRAWRD_FUND_CODE = 'ACG1')
         AND rorstat_pidm = rcresar_pidm
        AND spriden_pidm = rcresar_pidm
        AND  RCRAPP1_PIDM    = RCRESAR_PIDM 
        AND shrlgpa_pidm = rcresar_pidm
        AND  SORHSCH_PIDM   = RCRESAR_PIDM 
        AND  RORHSDT_PIDM   = RCRESAR_PIDM 
        AND  SGBSTDN_PIDM   = RCRESAR_PIDM    
        AND  SORLCUR_PIDM   = RCRESAR_PIDM 
        AND rnvand0_pidm = rorstat_pidm
        AND  RCRESAR_INFC_CODE = RCRAPP1_INFC_CODE 
        AND  RCRESAR_SEQ_NO      = RCRAPP1_SEQ_NO  
        AND  RCRAPP1_AIDY_CODE = RCRESAR_AIDY_CODE
        AND ROBINST_AIDY_CODE = RCRESAR_AIDY_CODE
        AND  RCRESAR_AIDY_CODE = '&AIDY_CODE'
        AND rorstat_aidy_code = rcresar_aidy_code
        AND rnvand0_aidy_code = rcresar_aidy_code
        AND spriden_change_ind IS NULL
        ORDER BY name

    Frank Kulash wrote:
    Hi
    blackhole82 wrote:
    Yeah I realized that I was probably mixing styles after it wouldn't work. What you suggested does execute, so I assume it's right even though I'm not getting any rows at the moment. Don't assume it's correct: verify it
    I suggest re-writing the query using all ANSI syntax.
    Start with just two tables. Make sure that join is working.
    When you have something that works perfectly with just those tables, then add one more table.
    So if I wanted to left outer join onto shrlgpa too I would just need to add that underneath the join for rorenrl before the , and SORLCUR?In your existing query, it looks like shrlgpa is only connected to rcresar, using an inner join. Do you want to change that?At any rate, the order of tables using the old doesn't matter. Using ANSI notation, however, a join condition can only reference tables that have already been named in the same group of ANSI-joined tables.
    So you would probably would have to re-arrange the FROM clause.
    Sorry, I don't understand exactly what you want to do, so I can't tell you exactly how to do it.
    Make you best guess, and try it.
    If it doesn't produce the results you want, and you can't figure out how to fix it, then post the query, some sample data, and the desired results. If you post just the revised query, and a description of the problem, I'll try to answer, but without the sample data and desired results I can't guarantee that I can.Well I'm getting rows and the data seems to go with the query I had before using the outer join except for the records that have no record on shrlgpa. It appears that by having the clauses
    AND shrlgpa_hours_earned BETWEEN 0 AND 29
    AND shrlgpa_gpa_type_ind = 'O'that those I'm trying to pull in with the left outer join are being eliminated. Is it possible to still limit the hours earned while pulling in those who do not have a record on shrlgpa? Before I was just using a UNION to accomplish this, but I thought that I might be able to fine tune the query to eliminate the need for another UNION.

Maybe you are looking for

  • How can I subract a number of days from the sysdate() ?

    I need to display a date that is a certain number of days older than the current date. I tried <?xdoxslt:sysdate('yyyy-MM-dd') - 7?> but I get an error. Any suggestions would be appreciated.

  • Benefits of F110

    Dear All, Can anybody list out the benefits of F110 over the manual payment (F-53 & F-58) process. do elaborate. Regards

  • Order of deleting entities

    Hi, On my card in addition to the entities that are installed by default (card manager etc.) I have one applet, its exec load file and another exec load file that stores some libraries. If I issue one DELETE command with the three AIDs ( I even found

  • How To: ServerSide ?TEMPLATES? - Expert level help needed

    I dont know what this is called or how to search on it. But what I want is the ability to make changes to a template, upload JUST the template and have the files on the server get their structure etc from the template - WITHOUT having to download all

  • New css for {code} -

    Hi All, Editing in HTML mode, I overrided the CSS class 'jive-pre' with my own style and it looks like below. ranit@XE11GR2>> select user, sysdate from dual; USER                           SYSDATE RB1                            18-JUN-13 From now I'l