Been having a bit of trouble writing the WHERE clause logic.
In english:
Want to see all people who are not in the deceased list or in the exclusion list regardless of whether they have graduated or not, however if they are deceased or in the exclusion list and have graduated, they should be included/displayed in the query's output.
The statement below seems to be excluding the deceased that have not graduated, but are including people in the exclusion list who have not graduated.
If not deceased want them
If deceased but graduated want them
If not in the exclusion list want them
If in the exclusion list but graduated want them
In english:
Want to see all people who are not in the deceased list or in the exclusion list regardless of whether they have graduated or not, however if they are deceased or in the exclusion list and have graduated, they should be included/displayed in the query's output.
The statement below seems to be excluding the deceased that have not graduated, but are including people in the exclusion list who have not graduated.
If not deceased want them
If deceased but graduated want them
If not in the exclusion list want them
If in the exclusion list but graduated want them
Code:
SELECT *
FROM (qryFATT
LEFT JOIN sqlDeceased ON qryFATT.COHORT_PIDM = sqlDeceased.SPBPERS_PIDM)
LEFT JOIN sqlExclusionReason ON qryFATT.COHORT_PIDM = val(sqlExclusionReason.PERSON_UID)
WHERE sqlDeceased.SPBPERS_DEAD_IND Is Null
OR (sqlDeceased.SPBPERS_DEAD_IND = "Y" and graduated = 1)
OR sqlExclusionReason.REGISTRATION_REASON is null
OR (sqlExclusionReason.REGISTRATION_REASON is not null and graduated = 1);