Link to home
Start Free TrialLog in
Avatar of guinnie
guinnie

asked on

Oracle sql left join problem

Getting error at line 35

see attachment for entire code but

here are  the lines in question

  LEFT JOIN (select DISTINCT(PERSON_ID, SCHOOL_YEAR, SCHOOL_CODE) from FS_SE_STUDENT_SCHOOL_IEP) SCHOOLIEP
                 ON  SCHOOLIEP.PERSON_ID = STUDENT_REGISTRATIONS.PERSON_ID
                 AND SCHOOLIEP.SCHOOL_YEAR  = STUDENT_REGISTRATIONS.SCHOOL_YEAR
                 AND SCHOOLIEP.SCHOOL_CODE = STUDENT_REGISTRATIONS.SCHOOL_CODE
Avatar of Steve Wales
Steve Wales
Flag of United States of America image

No attachment here ... and no specific error message.  Please provide both?
ASKER CERTIFIED SOLUTION
Avatar of chaau
chaau
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
get rid of the duplicates and then leave the distinct out

 LEFT JOIN FS_SE_STUDENT_SCHOOL_IEP SCHOOLIEP
                 ON  SCHOOLIEP.PERSON_ID = STUDENT_REGISTRATIONS.PERSON_ID
                 AND SCHOOLIEP.SCHOOL_YEAR  = STUDENT_REGISTRATIONS.SCHOOL_YEAR
                 AND SCHOOLIEP.SCHOOL_CODE = STUDENT_REGISTRATIONS.SCHOOL_CODE
Be very careful with the word "distinct" in Oracle queries.  Yes, that keyword is supported in Oracle.  But it can cause two problems:
1. Oracle's definition of what "distinct" means may be different from what most humans expect, especially if there is a date column involved, and the date values include a non-midnight time-of-day.
2. This forces a sort operation, so depending on how many duplicate rows exists, this can add a significant performance penalty.