ANSI SQL JOIN

Hi
How to use ANSI SQL JOINS (9i) for below query
SELECT EMP.EMPNO,EMP_T.TNO,EMP_T.SAL1 FROM EMP,EMP_T WHERE EMP.EMPNO=EMP_T.TNO
UNION ALL
SELECT EMP.EMPNO,EMP_T.TNO,EMP_T.SAL2 FROM EMP,EMP_T WHERE EMP.EMPNO=EMP_T.TNO
UNION ALL
SELECT EMP.EMPNO,EMP_T.TNO,EMP_T.SAL3 FROM EMP,EMP_T WHERE EMP.EMPNO=EMP_T.TNO
EMPNO TNO SAL1
7369 7369 100
7499 7499 1000
7566 7566 400
7782 7782 4000
7369 7369 200
7499 7499 2000
7566 7566 500
7782 7782 5000
7369 7369 300
7499 7499 3000
7566 7566 600
EMPNO TNO SAL1
7782 7782 6000
Regards
MM

SELECT EMP.EMPNO,
       EMP_T.TNO,
       EMP_T.SAL1
FROM   EMP
JOIN   EMP_T ON ( EMP.EMPNO = EMP_T.TNO )
  UNION ALL
SELECT EMP.EMPNO,
       EMP_T.TNO,
       EMP_T.SAL2
FROM   EMP
JOIN   EMP_T ON ( EMP.EMPNO = EMP_T.TNO )
  UNION ALL
SELECT EMP.EMPNO,
       EMP_T.TNO,
       EMP_T.SAL3
FROM   EMP
JOIN   EMP_T ON ( EMP.EMPNO = EMP_T.TNO )

Similar Messages

  • OWB 10.2.0.4 ANSI SQL join problem

    Hi
    Its seams to me, that in OWB 10.2.0.4 there is something broken with ANSI SQL joins and instead of ANSI joins there is used oracle SQL joins only. Maybe someone can point some solutions? I can’t rewrite all mappings with union and other operators. And manually pl/sql editing also would be big problem.

    "Am I correct in assuming you did not code ANSI joins?" -> yes, i am coding Oracle SQL joins and with this option just generating ANSI joins.
    With ANSI SQL join you can use OR and IN operands (and code looks more readable).
    It is question of performance (so for example 80% of dataset you can join by one column other 15% by second etc ..). So this all can be rewritten also in Split->join->union all, but if you have several such joins, this will be painfully.

  • Converting oracle join to Ansi sql join

    Hi Guys,
    I am new to SQL and trying to convert the following Oracle query (joins) into ANSI sql joins...Can someone please help me?
    SELECT M.EXTERNALCODE, M.NAME AS MNAME, SC.BIRIM, SM.TRANSACTIONDATE, SMD.AMOUNT,
    SMD.UNITPRICE, SM.ID AS SMID, SMD.ID AS SMDID, F.NAME AS FNAME,
    IFNULL (SMD.AMOUNT, 0, SMD.AMOUNT) * IFNULL (SMD.UNITPRICE, 0, SMD.UNITPRICE) AS TOTALPRICE, SMD.AMOUNT AS RECEIVED_QUANTITY,
    PD.ORDERID, PD.AMOUNT QUANTITY, PO.PROCESSDATE
    FROM STOCKMAINTRANSACTION SM,
    STOCKMAINTRANSACTIONDETAIL SMD,
    MATERIAL M,
    STOCKCARD SC,
    FVSTOCK FVS,
    FIRM F,
    PURCHASEORDER PO,
    PURCHASEORDERDETAIL PD,
    PURCHASEORDERDETAILSUPPLIED PDS
    WHERE SM.ID = SMD.MAINTRANSACTIONID
    AND SMD.MATERIALID = M.ID
    AND SMD.STOCKCARDID = SC.ID
    AND SM.PROPREF = FVS.RECORDID(+)
    AND FVS.FIELDID(+) = 2559
    AND FVS.FLEVEL(+) = 'F'
    AND F.ID(+) = SUBSTR (FVS.FVALUE, 1, 9)
    AND SM.TRANSDEFID in (999,2329,2344,2370,150000903,150005362)
    AND SMD.CANCELLED = 0
    AND SMD.STOCKUPDATED = 1
    AND SMD.ID = PDS.STOCKMAINTRANSACTIONDETAILID
    AND PDS.ORDERDETAILID = PD.ORDERDETAILID
    AND PO.ORDERID = PD.ORDERID
    AND (M.ID = {@MATERIALID@} OR {@MATERIALID@} = 0)
    AND (SM.STOREID = {@STOREID@} OR {@STOREID@} = 0)
    AND (F.ID = {@SUPPLIERID@} OR {@SUPPLIERID@} = 0)
    AND SM.TRANSACTIONDATE BETWEEN {@STARTDATE@} AND {@ENDDATE@}
    ORDER BY F.NAME, M.EXTERNALCODE, SM.TRANSACTIONDATE
    Really appreciate the help!
    Thanks.

    Hi,
    Welcome to the forum!
    To convert to ANSI syntax, replace join conditions in the WHERE clause
    FROM           x
    ,             y
    WHERE         x.x1  = y.y1
    AND           x.x2  = y.y2with ON conditions in the FROM clause:
    FROM           x
    JOIN             y   ON    x.x1  = y.y1
                             AND   x.x2  = y.y2In inner joins, conditions that do not reference 2 tables are not really join conditions, so it doesn't matter if they are in the FROM clause or in the WHERE clause.
    In your case
    SM.TRANSDEFID in (999,2329,2344,2370,150000903,150005362)could be part of a join condition involving sm, or it could be in the WHERE clause. Most people find it clearer if 1-table conditions like this are in the WHERE clause.
    Again, this only applies to inner joins. For outer joins, all conditions that apply to a table that may lack matching rows must be included in the FROM clause, like this:
    LEFT OUTER JOIN  fvstock   fvs  ON   sm.propref       = fvs.recordid
                                    AND  fvs.fieldid  = 2559
                        AND  fvs.flevel   = 'F'Try it.
    If you have trouble, post your best attempt, along with CREATE TABLE and INSERT statements for a little sample data from all the tables involved, and the results you want from that data. Simplify the problem. Post only the tables and columns that you don't know how to handle.
    See the forum FAQ {message:id=9360002}
    user8428528 wrote:
    AND (M.ID = {@MATERIALID@} OR {@MATERIALID@} = 0)
    AND (SM.STOREID = {@STOREID@} OR {@STOREID@} = 0)
    AND (F.ID = {@SUPPLIERID@} OR {@SUPPLIERID@} = 0)
    AND SM.TRANSACTIONDATE BETWEEN {@STARTDATE@} AND {@ENDDATE@}This is not valid Oracle SQL. Is {@MATERIALID@} some kind of variable?

  • ANSI SQL 92 SYNTAX OUTER JOIN PERFORMANCE ISSUE

    Good Morning
    Could anyone explain why the excution time for these two (ment to be identical)
    queries run so differently.
    oracle syntax execution time 1.06 seconds
    select COUNT(*) from
    PL_EVENT_VIEW pev,
    PL_EVENT_STAFF_VIEW pesv
    WHERE pev.EVENT_ID=PESV.EVENT_ID(+)
    AND pev.WEEKS=PESV.WEEK_NUM(+)
    AND pev.event_id=2520
    ansi sql 92 syntax execution time 7.05 seconds
    select COUNT(*) from
    PL_EVENT_VIEW pev
    LEFT JOIN PL_EVENT_STAFF_VIEW pesv
    ON (pev.EVENT_ID=PESV.EVENT_ID
    AND pev.WEEKS=PESV.WEEK_NUM)
    WHERE pev.event_id=2520
    Thanks
    David Hills

    BTW Oracle outer join operator (+) and ANSI SQL OUTER JOIN syntax are NOT equivalent. Consider following:
    DROP TABLE T1;
    CREATE TABLE T1 (C1 NUMBER);
    DROP TABLE T2;
    CREATE TABLE T2 (C2 NUMBER);
    DROP TABLE T3;
    CREATE TABLE T3 (C3 NUMBER);
    -- Following SELECT works:
    SELECT COUNT(*)
         FROM T1, T2, T3
         WHERE C2 = C1
              AND C3(+) = C1
    COUNT(*)
    0
    -- But:
    SELECT COUNT(*)
         FROM T1, T2, T3
         WHERE C2 = C1
              AND C3(+) = C1
              AND C3(+) = C2
    AND C3(+) = C1
    ERROR at line 4:
    ORA-01417: a table may be outer joined to at most one other table
    -- However with ANSI syntax:
    SELECT COUNT(*)
         FROM T1
         JOIN T2 ON (C2 = C1)
         LEFT JOIN T3 ON (C3 = C1 AND C3 = C2)
    COUNT(*)
    0

  • ANSI SQL Syntax - What belongs to join-clause and what to where-clause

    Hello,
    we currently have a discussion about the ANSI SQL Syntax where we do not agree what belongs to the join clause and what belongs to the where clause in an ANSI Sytnax SQL Query.
    Lets say there is a query like this:
    +SELECT *+
    FROM employees emp, departments dept
    WHERE emp.dept_country = dept.dept_country
    AND emp.dept_name = dept.dept_name
    AND dept.dept_type = 'HQ'
    AND emp.emp_lastname = 'Smith'
    Primary key of the departments table is on the columns dept_country, dept_name and dept_type. We have a Oracle database 10g.
    Now I have rewritten the query to Ansi Syntax:
    +SELECT *+
    FROM employees emp
    JOIN departments dept
    ON emp.dept_country = dept.dept_country AND emp.dept_name = dept.dept_name
    WHERE dept.dept_type = 'HQ'
    AND emp.emp_lastname = 'Smith'
    Another developer says that this is not completely correct, every filter on a column that belongs to the primary-key of the joined table has to be in the join clause, like this:
    +SELECT *+
    FROM employees emp
    JOIN departments dept
    +ON emp.dept_country = dept.dept_country AND emp.dept_name = dept.dept_name AND dept.dept_type = 'HQ'
    WHERE emp.emp_lastname = 'Smith'
    Can somebody tell me which on is correct?
    Is there any definition for that? I couldn't find it in the Oracle Database definition.
    I just found out the names of the ANSI documents here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/ap_standard_sql001.htm#i11939
    I had a look at the ANSI webstore but there you have to buy the PDF files. In my case thats exaggerated because both of the Queries work and i am just interessted if there is one correct way.
    Thank you in advance
    Marco

    Hi,
    As i guideline i would say, answer the question: should the result of the join be filtered or should only filtered rows be joined from a particular table?
    This is helpful in the case of outer joins also, for inner joins it doesnt matters as said already be former posters, where there may be hughe semantical differences depending of where the predicates are placed.
    From performance view, if we talk about oracle, take a look a the execution plans. You will see that there is (probably) no difference in case of inner joins. Even in case of outer joins the optimizer pushes the predicate as a filter towards the table if it semantically possible.
    Regards

  • 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

  • Differences between ANSI SQL and Oracle 8/9

    Hallo,
    i'm looking for good online texts or books concerning the problem "Differences between ANSI SQL and different database implementations (ORACLE, Informix, MySQL...)" I want to check a program written in C (with ESQL) that works with an Informix-DB. In this code i want to find code that is specific to the Informix-DB. I want to change the database, so all the code should be independent from a DB. Does anybody know texts or books concerning this problem?
    thx
    Marco Seum

    Basically there is syntax difference between both of them.
    Lets say i want to join two table EMP and DEPT based on DEPTNO.
    With Oracle SQL format its like this.
    select e.*
      from emp e, dept d
    where e.deptno = d.deptnoHere the joining condition goes in the WHERE clause.
    With ANSI SQL format its like this.
    select e.*
      from emp e
      join dept d
        on e.deptno = d.deptnoHere the join condition is mentioned separately and not in WHERE clause.
    Oracle supports ANSI SQL starting from 9i version.
    You can read more about the syntax difference Here

  • What is Difference between ANSI SQL and ORACLE SQL

    Hi,
    I am going to take the assesment test for ANSI SQL Programming before that i want to know any difference between ANSI SQL and ORACLE SQL?
    I am studying for SQL but the test will be ANSI SQL please let me give an idea about the both.
    Thanks
    Merina Roslin

    Basically there is syntax difference between both of them.
    Lets say i want to join two table EMP and DEPT based on DEPTNO.
    With Oracle SQL format its like this.
    select e.*
      from emp e, dept d
    where e.deptno = d.deptnoHere the joining condition goes in the WHERE clause.
    With ANSI SQL format its like this.
    select e.*
      from emp e
      join dept d
        on e.deptno = d.deptnoHere the join condition is mentioned separately and not in WHERE clause.
    Oracle supports ANSI SQL starting from 9i version.
    You can read more about the syntax difference Here

  • Using ANSI sql in forms 9i triggers

    hi,
    could use some help here please!
    I am getting errors when trying to compile triggers in forms 9i against a 9i DB which include cursors or sql select's which are written using the ANSI join syntax.
    example:
    declare
    cursor cur_test is
    select dual1.dummy "dual1", dual2.dummy "dual2"
    from (dual dual1 inner join dual dual2 on dual1.dummy = dual2.dummy);
    begin
         null;
    end;
    when I try and compile I get error message "103" which seems to think that the SQL is not valid. If I put the same statements into recordgroups they will compile, and they run via SQL*Plus OK.
    versions are:
    Forms [32 Bit] Version 9.0.2.9.0 (Production)
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    Oracle Toolkit Version 9.0.4.0.23 (Production)
    PL/SQL Version 9.0.1.3.1 (Production)
    Oracle Procedure Builder V9.0.2.0.7 Build #1022 - Production
    database: 9.2.0.1.0
    Any ideas?!
    thanks,
    Pete

    If you remember that Sybase and MS worked together on SQLServer. Version 6.5 was pretty much the same database server. MS then built version 7.0 leaving Sybase behind. They added ANSI standard joins to their db. What did they get? PROBLEMS. Every patch contained fixes for ANSI standard joins. Even SQLServer 2000 has problems with it.
    Oracle now trys to follow MS and add ANSI joins to their database. What did it give them? BUGS. Remember this one?
    select * from sys.role$ cross join dual
    http://otn.oracle.com/deploy/security/pdf/sql_joins_alert.pdf
    Use standard joins and not ANSI joins. That will solve this problem.

  • 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

  • Iso/ansi sql-99 query

    hi..
    i'm new for oracle ..
    i hav one doubt .. what is the difference between normal join and iso/ansi sql-99 joins...
    is any advantage ..
    query e.g:
    SELECT c.course_name, c.period, e.student_name
    FROM course c, enrollment e
    WHERE c.course_name = e.course_name(+)
    AND c.period = e.period(+);
    sql-99 format :
    SELECT c.course_name, c.period, e.student_name
    FROM enrollment e RIGHT OUTER JOIN course c
    ON c.course_name = e.course_name
    AND c.period = e.period;

    Hi
    -It is analogous to joining a table, and avoiding the "where" clause
    -It allows easier product migration and a reduced learning curve when cross-training
    -there is no performance increase compared to the existing syntax.
    I hope u got it
    Khurram Siddiqui
    [email protected]

  • ANSI SQL syntax?

    Hi all,
    I have a simple query
    SELECT A.*, B.Dstrct_Code FROM MSF601 A, MSF600 B
    WHERE ALTERNATE_REF LIKE 'PF%'
    AND A.alt_ref_code = B.Equip_No
    AND B.Dstrct_Code = 'ACME';
    which works fine, but I want to convert it to ANSI
    SQL syntax, so I tried
    SELECT A.*, B.Dstrct_Code FROM MSF601 A, MSF600 B
    WHERE ALTERNATE_REF LIKE 'PF%'
    INNER JOIN ON A.alt_ref_code = B.Equip_No
    AND B.Dstrct_Code = 'ACME';
    but I get
    ERROR at line 3:
    ORA-00933: SQL command not properly ended
    Could some kind soul explain why?
    Paul...

    An example that looks a lot like your example:
    SQL> select dept.*
      2       , emp.ename
      3    from dept, emp
      4   where dept.dname like '%A%'
      5   inner join on dept.deptno = emp.deptno
      6     and emp.sal > 1000
      7  /
    inner join on dept.deptno = emp.deptno
    FOUT in regel 5:
    .ORA-00933: SQL command not properly ended
    SQL> select dept.*
      2       , emp.ename
      3    from dept
      4         inner join emp on dept.deptno = emp.deptno
      5   where dept.dname like '%A%'
      6     and emp.sal > 1000
      7  /
                                    DEPTNO DNAME          LOC           ENAME
                                        30 SALES          CHICAGO       ALLEN
                                        30 SALES          CHICAGO       WARD
                                        20 RESEARCH       DALLAS        JONES
                                        30 SALES          CHICAGO       MARTIN
                                        30 SALES          CHICAGO       BLAKE
                                        10 ACCOUNTING     NEW YORK      CLARK
                                        20 RESEARCH       DALLAS        SCOTT
                                        10 ACCOUNTING     NEW YORK      KING
                                        30 SALES          CHICAGO       TURNER
                                        20 RESEARCH       DALLAS        ADAMS
                                        20 RESEARCH       DALLAS        FORD
                                        10 ACCOUNTING     NEW YORK      MILLER
    12 rijen zijn geselecteerd.Regards,
    Rob.

  • Generate ANSI SQL with Oracle IKM

    Is it possible for ODI to generate ANSI SQL with the Oracle IKM?
    I have used ANSI joins in a filter in an interface, now when I run the interface I get the error: ORA-25156: old style outer join (+) cannot be used with ANSI joins.
    I would prefer to use ANSI joins in my filters instead of the old style (+) syntax. Is this possible?

    Sure,
    Go to topology, edit your Oracle technology , on SQL tab change it over to ordered joins - clause location - From , you can specify the keywords left join, right join, full outer join etc to get rid of your '(+)'

  • Oracle SQL / Ansi SQL

    Hey,
    one of my colleagues managed to create a SQL-statement (in ansi-sql-syntax) that just blocks the session and gives no response at all.
    When I rewrote the statement, it gave results within a second.
    It's not quite possible to provide a sample-case, but maybe someone here has an idea why the first statement doesn't work, and the second does?
    First:
    ====
    SELECT c.CONTRACTID as ENTITEITID,
    v.VASTSTELLINGCODE,
    '' as INFO,
    v.CAMPAGNE
    FROM NFD_CONTRACT c
    INNER JOIN NFD_OVK o ON o.OVKID = c.OVKID
    INNER JOIN NFD_VSTDEFCMP v ON v.VASTSTELLINGCODE = 'C77' AND v.CLASSIFICATIECODE = o.CLASSIFICATIECODE AND v.CAMPAGNE = o.CAMPAGNE
    AND Nfd_Vaststellingen_Pck.NFD_IS_DATUM_VST_VALID('C77',o.CAMPAGNE,'Contract',o.CLASSIFICATIECODE) = 1
    INNER JOIN NFD_BETROKKENPSN_CON psn ON c.CONTRACTID = psn.CONTRACTID
    INNER JOIN (SELECT a.aangifteid, a.psn_nmr, a.psnrolid, a.oogstjaar,
    case when exists (SELECT ENTITEITID FROM NFD_VST_OA04_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    when exists (SELECT ENTITEITID FROM NFD_VST_OA05_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    when exists (SELECT ENTITEITID FROM NFD_VST_OA06_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    else 0
    end AS OA_Heeft_E
    FROM NFD_AANGIFTE a
    WHERE AANGIFTETYPE = 'Oogstaangifte') vst ON psn.PSN_NMR = vst.PSN_NMR AND psn.PSNROLID = vst.PSNROLID
    AND o.CAMPAGNE = vst.OOGSTJAAR AND vst.OA_Heeft_E = 1
    Second:
    ======
    SELECT c.CONTRACTID as ENTITEITID,
    v.VASTSTELLINGCODE,
    '' as INFO,
    v.CAMPAGNE
    FROM NFD_CONTRACT c
    ,nfd_ovk o
    ,nfd_vstdefcmp v
    ,nfd_betrokkenpsn_con psn
    ,(SELECT a.aangifteid, a.psn_nmr, a.psnrolid, a.oogstjaar,
    case when exists (SELECT ENTITEITID FROM NFD_VST_OA04_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    when exists (SELECT ENTITEITID FROM NFD_VST_OA04M_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    when exists (SELECT ENTITEITID FROM NFD_VST_OA04S_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    when exists (SELECT ENTITEITID FROM NFD_VST_OA05_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    when exists (SELECT ENTITEITID FROM NFD_VST_OA06_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
    else 0
    end AS OA_Heeft_E
    FROM NFD_AANGIFTE a
    WHERE AANGIFTETYPE = 'Oogstaangifte') vst
    WHERE o.OVKID = c.OVKID
    AND v.VASTSTELLINGCODE = 'C77' AND v.CLASSIFICATIECODE = o.CLASSIFICATIECODE AND v.CAMPAGNE = o.CAMPAGNE
    AND Nfd_Vaststellingen_Pck.NFD_IS_DATUM_VST_VALID('C77',o.CAMPAGNE,'Contract',o.CLASSIFICATIECODE) = 1
    AND c.CONTRACTID = psn.CONTRACTID
    AND psn.PSN_NMR = vst.PSN_NMR AND psn.PSNROLID = vst.PSNROLID
    AND o.CAMPAGNE = vst.OOGSTJAAR AND vst.OA_Heeft_E = 1

    hey riedelmie,
    off course the second statement is different.
    I rewrote the query so the inner joins are being replaced by where-clauses with the table-names all in the from-clause.
    In the second statement there are two extra when-clauses but they should also be in the first statement (the problem is still there, so data could indeed be different, but the problem is the same)
    Tnx.
    Greetings,
    Dave
    Message was edited by:
    geysemansdave
    added text about the when-clauses

Maybe you are looking for

  • Changed View Still Shows Original View Name

    I'm using Crystal XI I built a report (MyReport_v1.rpt) using a view (vwMyView_v1) created in SQL Server.  Now I have to modify the view enough that it would affect the report.  So I made a copy of the report (MyReport_v2.rpt) and a copy of the view

  • Clearing data showing the error ..

    Hi experts , We use the clearing data , through the run package .. But while clearing the data , its show error .. Please find below the error TOTAL STEPS  3 1. Export_Zero:        completed  in 0 sec. 2. Load Cube:          Failed  in 0 sec. [Select

  • How to enable Account assignment tab in CCM SRM 7.0

    Dear SRM Gurus, We have requirement to activate account assignment tab in Item level of Central Contract management in SRM 7.0 Regards, Vinod

  • Burn folder do not see my blank CD or DVD

    burn folder ask for blank media to insert even if a blank media in drive i do not use this feature often but this is quite annoying with Disk Utility i do not have problems but i really need to solve problem with burn folder thank you for your help!

  • PID Override

    Hey, I am trying to put a boolean into manual override switch into my PID setup for a temperature control. In order to do this, I want to have a numerical control which is in oC on the front panel. However my heater will respond to Volts. In order to