Query builder bug in outer joins ?

I understood that if you were joining two tables A and B, the following was a
LEFT OUTER JOIN
SELECT A.COL, B.COL
FROM A, B
WHERE A.ID = B.ID (+)
ie: a LEFT outer join has the (+) on the Right-hand table.
However, query builder puts the (+) on the Left-hand table.
Same for a RIGHT outer join - I think the (+) should be on the Left-hand table, but query builder puts it on the Right-hand table.
Cheers,
Andrew
(running Version 2.1.0.00.39)

Hi Andrew,
I just played a little with the query builder and created a join between two of my tables:
PROJECTS and ACTIVITIES, linked via KCC.
When I create a left outer join in query builder, I get the following result:
select     "PROJECTS"."KCC" as "KCC"
from     "ACTIVITIES" "ACTIVITIES",
     "PROJECTS" "PROJECTS"
where "PROJECTS"."KCC"(+) ="ACTIVITIES"."KCC"
Which is correct: Left refers to the first table in the from clause (ACTIVITIES) and places the (+) on the other table!
Left and right refers to the order of tables in the from clause, not in the where clause. Query builder sorts the tables in FROM alphabetically, maybe this is differing from the graphical order in query builder.
Regards
Alex

Similar Messages

  • Query by example and outer join supported?

    Does TopLink support outer joins when using query by example and cursored streams? I am having problems getting this to work. It seems to completely ignore the requested outer join.
    I have tried several variations of what is below, but have never seen TopLink generate the outer join. This is against Oracle 9i on TopLink 9.0.4.5.
    Customer 1->1 Address (using valueholder indirection)
    ReadAllQuery q = new ReadAllQuery();
    q.setReferenceClass(Customer.class);
    QueryByExamplePolicy policy = new QueryByExamplePolicy();
    policy.addSpecialOperation(String.class, "like");
    q.setQueryByExamplePolicy(policy);
    ExpressionBuilder builder = q.getExpressionBuilder();
    Expression addressExp = builder.getAllowingNull("address");
    q.addJoinedAttribute(addressExp);
    q.addOrdering(addressExp.get("city").ascending());
    q.useCursoredStream(end-start, end-start);
    q.setExampleObject(exampleCustomer);
    CursoredStream stream = (CursoredStream)s.executeQuery(q);
    ...iterate through the stream...
    Note, that the database level relationship is expressed through a target foreign key.
    (     addressMapping.addTargetForeignKeyFieldName("ADDRESS.CUSTOMER_ID", "CUSTOMER.CUSTOMER_ID");)
    Any help would be appreciated.
    Thanks,
    Kevin

    Kevin,
    I spoke too soon. All you need to do is use the getAllowingNull in the ordering expression and not use the addJoinedAttribute. With this you can use query-by-example with additional outer-joined ordering.
    Here is an example based on the Employee demo:
    ReadAllQuery raq = new ReadAllQuery(Employee.class);
    ExpressionBuilder eb = raq.getExpressionBuilder();
    raq.addOrdering(eb.getAllowingNull("address").get("city").ascending());
    Employee exampleEmp = new Employee();
    exampleEmp.setLastName("%");
    // My default constructor populates the period so I'll null them so
    // they are not included in the selection criteria of the example object
    exampleEmp.getPeriod().setStartDate(null);
    exampleEmp.getPeriod().setEndDate(null);
    QueryByExamplePolicy policy = new QueryByExamplePolicy();
    policy.addSpecialOperation(String.class, "like");
    raq.setQueryByExamplePolicy(policy);
    raq.setExampleObject(exampleEmp);
    List emps = (List) session.executeQuery(raq);
    I hope this helps,
    Doug

  • Configure "Query Builder" for Theta-Style Joins over ANSI-Style Joins

    Can SQL Developer be configured to auto generate theta-style joins instead of ANSI-style joins when building queries? This happens when I generate a query using the Query Builder and then switch over to the Worksheet tab to see the SQL code.
    Sample code:
    Theta-style join syntax uses commas to separate multiple table names and creates the joins in the Where clause:
    SELECT c.name
    FROM instructors i, courses c
    WHERE i.firstname = 'Mary' AND i.lastname = 'Williams'
    AND i.course_id = c.course_id;
    ANSI syntax uses the JOIN and ON keywords instead:
    SELECT c.name
    FROM instructors i JOIN courses c
    ON i.course_id = c.course_id
    WHERE i.firstname = 'Mary' AND i.lastname = 'Williams';

    Hi Wes,
    There is no preference for configuring this that I know of, but Query Builder is fairly clever about detecting your flavor of SQL from the worksheet then sticking with it. If you design it graphically, the default flavor is ANSI, but QB seems to respect any worksheet edits that switch it to another flavor. I wouldn't vouch for that absolutely, but perhaps it's behavior you can take advantage of.
    Regards,
    Gary
    SQL Developer Team

  • How to merge 3 different query results using full outer join?

     Hi all This is my my query for 2 results
    with t1 as (
    select trans.crAcc_id,trans.cr_amt,row_number() over (order by trans.head_id) rn from Acttrans trans,
     Acttranhead head where trans.head_id in(select link_id from acttrans where head_id=12) and trans.crAcc_id!=0
     and head.head_id=trans.head_id
    t2 as (
    select trans.drAcc_id,trans.dr_amt,head.[Vouc_No],head.[Vouc_Date] ,head.[Check_No],head.[Check_Date],head.[stat],row_number() over (order by trans.head_id) rn from Acttrans trans,
     Acttranhead head where trans.head_id=12 and trans.drAcc_id!=0
     and head.head_id=trans.head_id
     select t1.crAcc_id, t1.cr_amt,t2.[Vouc_No],t2.[Vouc_Date] ,t2.[Check_No],t2.[Check_Date],t2.[stat],t2.drAcc_id,t2.dr_amt from t1
      full outer join t2 on t1.rn = t2.rn
    Query 3: SELECT [CrAcc_Id]  FROM [KSSDATA].[dbo].[ActTrans] where head_id=12 and crAcc_id!=0
    and i want to add Query3 result to the ABOVE RESULT but i am unable add third result using full outer join
    Thanks
    Balu D

    >>>but i am unable add third result using full outer join
    Do you get the error or wrong result?
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • 1.5.4 Query Builder Bug?

    I was testing the Query Builder with SQL developer version 1.5.4. It seems to have problems when trying to add the same table twice to the query.
    Example was to use the employees table from HR schema to create a query showing employees and managers. When clicking the second time on the employees table then the query builder did just "hang" there indefinitly.
    Did I miss some important step like giving alias names to the tables?

    There's an accepted enhancement request for this at the Echange. Go vote to add weight for future implementation.
    Regards,
    K.

  • Query Plan Question for Outer Join

    I have the following join query:
    select unique ep.ACT_UID,
    ep.SE_REQ_TS,
    sr.SERVICE_NM
    from
    eaisvcs.Service_requests sr,
    eaisvcs.SERVICE_EPISODE ep
    where
    ep.ACT_UID = sr.ACT_UID;
    I have an index on the act_uid in both tables, and the statistics are up-to-date. There are about 3.2 million rows in each table. 10% of the act_uid's that are in the ep table that do not have a match in the sr table. Other than that, most id's match up between the tables.
    Here is the query plan:
    ID PARENT_ID OPERATION OPTIONS
    0 SELECT STATEMENT
    1 0 SORT UNIQUE
    2 1 MERGE JOIN
    3 2 SORT JOIN
    4 3 TABLE ACCESS FULL
    5 2 SORT JOIN
    6 5 TABLE ACCESS FULL
    I cannot figure out why a table scan is being performed every time on both tables. The Act_UID is the PK in the ep table. There is a composite index (act_uid, sev_seq_no) in the sr table. the act_id is a varchar2 column in both tables. The sev_seq_no column is numeric.
    Any ideas or insights about this would be greatly appreciated.
    Thanks!

    The plan can be good.
    Oracle choose a full table scan for these reason too:
    - sr.SERVICE_NM is not a part of the index and so a full table scan is less expensive. If you will add this field to your composite index Oracle will probably take this new index.
    Bye, Aron

  • SCORE(n) returning zero values in an outer join query

    Hello all,
    Is there any way to get a query that contains an outer join to return proper scores. I couldn't find out why this was happening in my query, but I'm getting a score values of 0 on most results.
    Below are queries with result sets. As you can see the results that are scoring in the second query are scoring correctly, but only two have scores.
    - - - Query 1, no outer join - - -
    SELECT DISTINCT SCORE(0) AS scr,
    file_repository.file_id,
    file_repository.file_title
    FROM file_repository
    WHERE CONTAINS(index_url,'SYN(dui,a_thesaurus)', 0) > 0
    ORDER BY scr ASC
    SCR FILE_ID FILE_TITLE
    7 136 Prisoners
    7 240 Drug booklet
    8 64 Communications
    8 146 Rates
    8 168 Vehicle Collisions
    8 206 document4
    14 207 document5
    14 211 document5
    15 74 Diplomatic Personnel
    22 214 documentB
    30 81 DUI and PCA Offences
    - - - Query 2, with outer join - - -
    SELECT DISTINCT SCORE(0) AS scr,
    file_repository.file_id,
    file_repository.file_title
    FROM file_repository, file_security
    WHERE CONTAINS(index_url,'SYN(dui,a_thesaurus)', 0) > 0
    AND file_repository.file_id = file_security.file_id(+)
    AND file_security.auth_id = 0
    ORDER BY scr asc
    SCR FILE_ID FILE_TITLE
    0 74 Diplomatic Personnel
    0 81 DUI and PCA Offences
    0 136 Prisoners
    0 146 Rates
    0 168 Vehicle Collisions
    0 206 document4
    0 207 document5
    0 214 documentB
    0 240 Drug booklet
    8 64 Communications
    14 211 document5
    This is on Oracle 9i using Oracle Text.
    Thanks in advance

    To do this wouldn't you need to know the data in advance? The real source table had 1800 organisations and 8,000,000 transactions.
    I Tried this as well, creating a pl/sql package as follows.
    create or replace PACKAGE stack AS
    TYPE gnt_push_numbers IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
    TYPE gvt_push_varchars IS TABLE OF VARCHAR(1000) INDEX BY PLS_INTEGER;
    gna_push_numbers gnt_push_numbers;
    gva_push_varchars gvt_push_varchars;
    FUNCTION PUSH ( pn_push_var NUMBER, pn_offset NUMBER) RETURN NUMBER DETERMINISTIC;
    FUNCTION PUSH ( pv_push_var VARCHAR, pn_offset NUMBER) RETURN VARCHAR DETERMINISTIC;
    FUNCTION POP_NUM ( pn_offset NUMBER) RETURN NUMBER DETERMINISTIC;
    FUNCTION POP_VAR ( pn_offset NUMBER) RETURN VARCHAR DETERMINISTIC;
    END stack;
    CREATE OR REPLACE
    PACKAGE BODY "STACK" AS
    FUNCTION push(pn_push_var NUMBER, pn_offset NUMBER) RETURN NUMBER deterministic IS
    BEGIN
    gna_push_numbers(pn_offset) := pn_push_var;
    RETURN pn_push_var;
    END push;
    FUNCTION push(pv_push_var VARCHAR, pn_offset NUMBER) RETURN VARCHAR deterministic IS
    BEGIN
    gva_push_varchars(pn_offset) := pv_push_var;
    RETURN pv_push_var;
    END push;
    FUNCTION pop_num(pn_offset NUMBER) RETURN NUMBER deterministic IS
    BEGIN
    RETURN gna_push_numbers(pn_offset);
    END pop_num;
    FUNCTION pop_var(pn_offset NUMBER) RETURN VARCHAR deterministic IS
    BEGIN
    RETURN gva_push_varchars(pn_offset);
    END pop_var;
    END stack;
    Unfortunately it appears to act before the rows are sorted, so will only work in specialised circumstances, in that you have to ensure the rows have been sorted before the function is used.
    SELECT PUSH(COL), POP..(COL)
    FROM ( SELECT etc.
    Luckily the client decided they didn't want to mix their graphs any more so a more classic approach using a base table select for actuals and then a date table select with a sub-query columns for the projection provided a simple solution.

  • Outer Join problems - "ORA-30563 outer join operator (+) not allowed in select-list"

    Products: Discoverer 4.1.33.0.2
    (Admin and User/Plus)
    8i EE 8.1.7 (Discoverer server)
    8i EE 8.1.5 ('source data' server)
    Background assumptions: (1) If a column from an "outer-joined" table is compared to a constant, the outer join operator must be applied to that column in order for the outer join to work. (2) A 'Condition' specified in Discoverer User/Plus manifests as a comparison to a constant.
    I created a join in Admin between two folders, selected 'outer join on detail' option. In User/Plus, created worksheet containing columns from the joined folders. When no Conditions are NOT specified, results seem ok. However, when Condition IS added, worksheet encounters "ORA-30563 outer join operator (+) not allowed in select-list" and returns blank sheet.
    To workaround, created Custom folder with outer join in place. Didn't work either with Conditions specified. No error, but I think that because Discoverer did not 'outer join' the Condition column, the outer join was ignored.
    Any insights, ideas, or workarounds are much appreciated.
    -Jim

    If you build a query that uses an outer join then any items from the potentially deficient side of the join will have (+) appended to them everywhere in the sql. Up until 8.1.7 this was OK in the select list as it was just treated as noise and ignored - However this now fails with ORA-30563:
    outer join operator (+) not allowed in select-list...
    In 4.1.33.1.6 you get the error 'ORA-30563 outer join operator(+) not allowed in select list'.
    In 4.1.36.1.10 the query runs OK.. Your work around I would guess would be to create a custom folder as you suggested.

  • Non-ANSI Outer Join Operator Issue (reposted due to text issues)

    I am currently using Designer 11.5.0.0. Itu2019s XI Rel 2, but Iu2019m not sure what service pack. I have created several universes with outer joins against a SQL Server 2005 database, but when I try using them in a Crystal report, I get the following error:
    Failed to retrieve date from the database. Details: 42000:[Microsoft][ODBC SQL Server Driver][SQL Server] The query uses non-ANSI outer join operators (u201C=u201D or u201C=u201D). To run this query without modification, please set the compatibility level for current database to 80 or lower, using stored procedure sp_dbcmptlevel. It is strongly recommended to rewrite the query using ANSI outer join operators (LEFT OUTER JOIN, RIGHT OUTER JOIN). In the future versions of SQL Server, non-ANSI join operators will not be supported even in backward-compatibility modes.
    Here is my ODBC DSN configuration:
    Microsoft SQL Server ODBC Driver Version 03.85.1132
    Data Source Name: FlexOPS
    Data Source Description:
    Server: dalsvrw031
    Database: (Default)
    Language: (Default)
    Translate Character
    Data: Yes
    Log Long Running Queries: No
    Log Driver Statistics: No
    Use Integrated Security: No
    Use Regional Settings: No
    Prepared Statements Option: Drop temporary procedures on disconnect
    Use Failover Server: No
    Use ANSI Quoted Identifiers: Yes
    Use ANSI Null, Paddings and Warnings: Yes
    Data Encryption: No
    Okay, so I understand what the issue is. It appears that the version of Designer that I am using does not default the ANSI92 parameter to u201CYesu201D. So all the outer joins I have created in each of my universe are using the old *= as the join operator. And apparently, the ODBC driver I am using is not very happy with that.
    As I understand it from what Iu2019ve read on other sites, I have the following options:
    1) Set the ANSI92 parameter to Yes, drop all my joins, close and re-open Designer, and recreate all of the joins.
    2) Find a different driver or connectivity method that will support non-ANSI joins.
    3) Set my database back to SQL 2000 compatibility.
    Option 1 is unappealing as it will cause a lot of time redoing all the work that Iu2019ve spent the past month doing. Option 2 is only a band-aid fix at best. Option 3 really isnu2019t an option for us.

    So I am wondering what other options I have to change these non-ANSI joins to ANSI compatible joins. Do I need to update Designer with a service pack? Is there a script out there that will automatically do this in each of the universes? I would appreciate any suggestions or guidance on this.
    Thanks,
    Lee

  • Non-ANSI Outer Join Operator Issue

    I am currently using Designer 11.5.0.0.  Itu2019s XI Rel 2, but Iu2019m not sure what service pack.  I have created several universes with outer joins against a SQL Server 2005 database, but when I try using them in a Crystal report, I get the following error:
    Failed to retrieve date from the database.
    Details:  42000:[Microsoft][ODBC SQL Server Driver][SQL Server] The query uses non-ANSI outer join operators (u201C=u201D or u201C=u201D).  To run this query without modification, please set the compatibility level for current database to 80 or lower, using stored procedure sp_dbcmptlevel.  It is strongly recommended to rewrite the query using ANSI outer join operators (LEFT OUTER JOIN, RIGHT OUTER JOIN).  In the future versions of SQL Server, non-ANSI join operators will not be supported even in backward-compatibility modes.
    Here is my ODBC DSN configuration:
    Microsoft SQL Server ODBC Driver Version 03.85.1132
    Data Source Name: FlexOPS
    Data Source Description:
    Server: dalsvrw031
    Database: (Default)
    Language: (Default)
    Translate Character Data: Yes
    Log Long Running Queries: No
    Log Driver Statistics: No
    Use Integrated Security: No
    Use Regional Settings: No
    Prepared Statements Option: Drop temporary procedures on disconnect
    Use Failover Server: No
    Use ANSI Quoted Identifiers: Yes
    Use ANSI Null, Paddings and Warnings: Yes
    Data Encryption: No
    Okay, so I understand what the issue is.  It appears that the version of Designer that I am using does not default the ANSI92 parameter to u201CYesu201D.  So all the outer joins I have created in each of my universe are using the old *= as the join operator.  And apparently, the ODBC driver I am using is not very happy with that.
    As I understand it from what Iu2019ve read on other sites, I have the following options:
    1)   Set the ANSI92 parameter to Yes, drop all my joins, close and re-open Designer, and recreate all of the joins.
    2)   Find a different driver or connectivity method that will support non-ANSI joins.
    3)   Set my database back to SQL 2000 compatibility.
    Option 1 is unappealing as it will cause a lot of time redoing all the work that Iu2019ve spent the past month doing.  Option 2 is only a band-aid fix at best.  Option 3 really isnu2019t an option for us.
    So I am wondering what other options I have to change these non-ANSI joins to ANSI compatible joins.  Do I need to update Designer with a service pack?  Is there a script out there that will automatically do this in each of the universes?
    I would appreciate any suggestions or guidance on this.
    Thanks,
    Lee
    Edited by: Lee Vance on Jul 6, 2009 10:02 PM

    Hi,
    try the following:
    open your universe in the Universe designer, go to File->Parameter, select the Parameter tab and change the value of the ANSI92 parameter from No to Yes.
    Regards,
    Stratos

  • Best Practice - Outer Join between Fact and Dim table

    Hi Gurus,
    Need some advice on the below scenario
    I have an OOTB subject area and we have around 50-60 reports based on it. The related subject area Fact and Dim1 table are having inner join.
    Now I have a scenario for one report where outer join has to be implemented between Fact and Dim1. Here I am against changing the OOTB subject area join as the outer join will impact the performance of other 50-60 reports.
    Can anyone provide any inputs on what is the best way to handle this scenario?
    Thanks

    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.

  • Need help with an Outer Join

    I have the following query which has an outer join and it works perfectly and shows publication paragraph which don't have any maintenance records with a value of 0.
    However when I add to the where clause conditions such as lpm.fac_ident and lpm.start_date, the null values no longer show up in the query(see second SQL statement).
    I am new at SQL and am just trying to make this outer join work. Any help would be appreciated.
    -- THIS WORKS
    SELECT m.publication_paragraph, pm.description, pm.frequency, count(l.publication_paragraph) ACTIVITIES_PERFORMED
    FROM lpm_paragraph_mapping_table m, lpm l, pm_requirements_table pm
    WHERE m.paragraph_alias_mapping = l.publication_paragraph (+)
    GROUP BY m.publication_paragraph, pm.description, pm.frequency
    order by count(l.publication_paragraph);
    -- THIS DOES NOT WORK
    SELECT m.publication_paragraph, pm.description, pm.frequency, count(l.publication_paragraph) ACTIVITIES_PERFORMED
    FROM lpm_paragraph_mapping_table m, lpm l, pm_requirements_table pm
    WHERE m.paragraph_alias_mapping = l.publication_paragraph (+)
    AND l.fac_ident = 'EWR' AND TO_CHAR(l.start_date, 'YYYY') = '2010'
    GROUP BY m.publication_paragraph, pm.description, pm.frequency
    order by count(l.publication_paragraph);
    Edited by: George Heller on Jun 30, 2011 9:47 AM

    fabio_silva wrote:
    Hi,
    I just didn't get. The table (pm_requirements_table pm) haven't any join ???
    Regards,Forgive the ASCII art, but your query looks like:
    ----------  JOIN ----------
    | Alias M | ====> | Alias L |
    | Alias PM |
    ----------- The table pm_requirements_table is not joined at all. Unless it has only a single row, then your resultset will have 1 row for each row in lpm_paragraph_mapping_table (because of the outer join) times the number of rows in pm_requirements_table. Consider this simplified example.
    SQL> select * from t;
            ID DESCR
             1 T 1
             2 T 2
    SQL> select * from t1;
            ID DESCR
             1 T1 1
             2 T1 2
             3 T1 3
             4 T1 4
    SQL> select 1.id, t.descr, t1.descr
      2  from t, t1;
            ID DESCR      DESCR
             1 T 1        T1 1
             1 T 1        T1 2
             1 T 1        T1 3
             1 T 1        T1 4
             1 T 2        T1 1
             1 T 2        T1 2
             1 T 2        T1 3
             1 T 2        T1 4Here, my table t is the result from your join between lpm_paragraph_mapping_table and lpm. My table t1 is your pm_requirements_table. You need something more like:
    SQL> select 1.id, t.descr, t1.descr
      2  from t, t1
      3  where t.id = t1.id;
            ID DESCR      DESCR
             1 T 1        T1 1
             1 T 2        T1 2Assuming you fix that join, you can use a sub-query to apply the predicates to the lpm as Centinul showed, or, if you are on a current version of Oracle, use ANSI join syntax wich would look something like:
    SELECT m.publication_paragraph, pm.description, pm.frequency,
            count(l.publication_paragraph) ACTIVITIES_PERFORMED
    FROM lpm_paragraph_mapping_table m,
       LEFT JOIN lpm l,
          ON m.paragraph_alias_mapping = l.publication_paragraph and
             l.fac_ident = 'EWR' AND
             TO_CHAR(l.start_date, 'YYYY') = '2010'
       JOIN pm_requirements_table pm
          on something
    GROUP BY m.publication_paragraph, pm.description, pm.frequency
    ORDER BY count(l.publication_paragraph);Leaving aside the missing join, the reason why your query as posted does not work is that when there is not a match on m.paragraph_alias_mapping = l.publication_paragraph Oracle will "make up" rows form lpm with all null columns for each row in lpm_paragraph_mapping_table where there is no match. So, when you compare those made up rows from lpm, you are effectively saying where NULL = 'EWR' and TO_CHAR(NULL, 'yyyy') = '2010'. Null is never equal to anything. Any comparision against null is unknown, so the made up rows get filtered out by your predicate.
    John

  • Oracle outer join on  multiple tables throws error

    Hi ,
    We are using ansi joins with outer joins on multiple tables in oracle 9i.
    Now these queries have to be used in Oracle8i.
    Since Oracle8i does not support ansi sql we are replacing the ansi sql queries with the oracle joins.
    On trying the same we found that the following query
    select *from tab1 a, tab2 b, tab3 c where a.c1 = b.col1(+) and c.c2 = b.col2 (+)
    throws the error
    ORA-01417: a table may be outer joined to at most one other table.
    Is there a way to simulate this query without using the outer joins on multiple tables?
    thanks

    Try writing the query in this form:
    select * from
    (select t1.col1, t1.col2
    from schema.table1 t1, schema.table2 t2
    where t1.col1 = t2.col1(+)) t4,
    schema.table3 t3 where t4.col2 = t3.col2(+)
    In the subquery, you will have to list all the columns you want to see, and you will need to provide unique aliases for any columns with duplicate names. I tested this on 9i, and don't have an 8i system to work with, so I hope this helps.

  • 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.

  • Old outer join syntax produces different results from new syntax!

    I have inherited a query that uses the old outer join syntax but that is yielding correct results. When I translate it to the new outer join syntax, I get the results I expect, but they are not correct! And I don't understand why the old syntax produces the results it produces. Bottom line: I want the results I'm getting from the old syntax, but I need it in the new syntax (I'm putting it into Reporting Services, and RS automatically converts old syntax to new).
    Here's the query with the old outer join syntax that is working correctly:
    Code Snippet
    SELECT   TE = COUNT(DISTINCT T1.ID),
             UE = COUNT(DISTINCT T2.ID),
             PE = CONVERT(MONEY, COUNT(DISTINCT T2.ID)) / 
                  CONVERT(MONEY,COUNT(DISTINCT T1.ID))
    FROM     TABLE T1, TABLE T2
    WHERE    T1 *= T2
    In this query, much to my surprise, TE <> UE and PE <> 1. However, TE, UE, and PE seem to be accurate!
    Here's the query with the new outer join syntax that is working but not producing the results I need:
    Code Snippet
    SELECT   TE = COUNT(DISTINCT T1.ID),
             UE = COUNT(DISTINCT T2.ID),
             PE = CONVERT(MONEY, COUNT(DISTINCT T2.ID)) / 
                  CONVERT(MONEY,COUNT(DISTINCT T1.ID))
    FROM     TABLE T1 LEFT OUTER JOIN TABLE T2 ON T1.ID = T2.ID
    Though not producing the results I need, it is producing what would be expected: TE = UE and PE = 1.
    My questions:
    1) Can someone who is familiar enough with the old syntax please help me understand why TE <> UE and PE <> 1 in the first query?
    2) Can someone please tell me how to properly translate the first query to the new syntax so that it continues to produce the results in the first query?
    Thank you very much.

    How can we reproduce the issue?
    Code Snippet
    USE [master]
    GO
    EXEC sp_dbcmptlevel Northwind, 80
    GO
    USE [Northwind]
    GO
    SELECT
    TE
    = COUNT(DISTINCT T1.OrderID),
    UE = COUNT(DISTINCT T2.OrderID),
    PE = CONVERT(MONEY, COUNT(DISTINCT T2.OrderID)) /
    CONVERT(MONEY,COUNT(DISTINCT T1.OrderID))
    FROM
    dbo
    .Orders T1, dbo.Orders T2
    WHERE
    T1
    .OrderID *= T2.OrderID
    SELECT
    TE
    = COUNT(DISTINCT T1.OrderID),
    UE = COUNT(DISTINCT T2.OrderID),
    PE = CONVERT(MONEY, COUNT(DISTINCT T2.OrderID)) /
    CONVERT(MONEY,COUNT(DISTINCT T1.OrderID))
    FROM
    dbo
    .Orders T1
    LEFT OUTER JOIN
    dbo.Orders T2
    ON T1.OrderID = T2.OrderID
    GO
    EXEC sp_dbcmptlevel Northwind, 90
    GO
    Result:
    TE
    UE
    PE
    830
    830
    1.00
    TE
    UE
    PE
    830
    830
    1.00
    As you can see, I am getting same results.
    AMB

Maybe you are looking for

  • QuickTime Plug-In 7.2

    I am hoping that someone can help me with my problem, I got the following link:http://www.apple.com/macosx/ and I wanted to take the tour but when I press on what size I want a window drops down telling me "Unable to load plug-in, The page "Apple -Ma

  • How to search for specific match from an array?

    Hi Mike, Thanks for the reply. I am reading a position of switches whether ON/OFF. It is nothing but the digital inputs status from the field. I am Indexing that array, and connect it to the LED indicators to show the relevant status. Also I want to

  • Logging takes in the field for multi-camera set-up with OL

    Is there any way to designate separate cameras or link shots (to be labeled as CamA or CamB) to advance takes and make notes simultaneously? OL doesn't really seem set up to use with documentary style shooting with multiple cameras, but maybe there i

  • VISA Read Timeout and VISA Write not working

    I'm writing a program that sets a triangle wave pattern voltage (using Triangle Wave VI) to a DC power source (GWInstek PST-3202) through a RS-232 connection.  I know my instrument parameters are set up correctly because I've been able to control thi

  • Loading an image in a JScrollPane

    Hello I have a little problem with an image in a JscrollPane. I load my image well, but when it appears in the scroll pane, the vertical and horizontal bars doesn't appear. I have to resize my window with the mouse, and then I can see them. Who knows