I'm hoping someone can help me figure this statement out. This is a compliant/non compliant query for various immunizations our students have (or not).
It lists students' names, immunizations and if they are compliant (Y/N). Everything works the way it is.
select
student.lname, student.fname,
i.Description Immunization,
CASE
WHEN TotalReq -
(case when immdate1 is null then 0 else 1 end + case when immdate2 is null then 0 else 1 end + case when immdate3 is null then 0 else 1 end + case when immdate4 is null then 0 else 1 end + case when immdate5 is null then 0 else 1 end + case when immdate6 is null then 0 else 1 end + case when immdate7 is null then 0 else 1 end + case when immdate8 is null then 0 else 1 end)
<= 0
THEN 'y'
ELSE 'N'
END AS compliant
FROM student cross join immunization i left join StImmunization si on si.sno =...<= 0