You should move the constraints on prescriptions.filldate
into the ON
condition of the join, and remove it from the where
clause:
LEFT OUTER JOIN prescriptions ON prescriber.dea_no = prescriptions.dea_no
AND prescriptions.filldate >= '09-01-12'
AND prescriptions.filldate <= '09-17-12'
Otherwise, entries for which there are no prescriptions
end up with null
s in prescriptions.filldate
, and the WHERE
clause throws them away.