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.PERS ON_ID
AND SCHOOLIEP.SCHOOL_YEAR = STUDENT_REGISTRATIONS.SCHO OL_YEAR
AND SCHOOLIEP.SCHOOL_CODE = STUDENT_REGISTRATIONS.SCHO OL_CODE
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.PERS
AND SCHOOLIEP.SCHOOL_YEAR = STUDENT_REGISTRATIONS.SCHO
AND SCHOOLIEP.SCHOOL_CODE = STUDENT_REGISTRATIONS.SCHO
No attachment here ... and no specific error message. Please provide both?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.PERS ON_ID
AND SCHOOLIEP.SCHOOL_YEAR = STUDENT_REGISTRATIONS.SCHO OL_YEAR
AND SCHOOLIEP.SCHOOL_CODE = STUDENT_REGISTRATIONS.SCHO OL_CODE
LEFT JOIN FS_SE_STUDENT_SCHOOL_IEP SCHOOLIEP
ON SCHOOLIEP.PERSON_ID = STUDENT_REGISTRATIONS.PERS
AND SCHOOLIEP.SCHOOL_YEAR = STUDENT_REGISTRATIONS.SCHO
AND SCHOOLIEP.SCHOOL_CODE = STUDENT_REGISTRATIONS.SCHO
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.
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.