Left Outer Join Not Working?

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 nulls in prescriptions.filldate, and the WHERE clause throws them away.


Here you can find a brief description about query processing phases (it's common for most DBMSes). You will find out there, that for OUTER JOIN:

  1. first CARTESIAN JOIN is produced,
  2. than the ON condition is performed on result set producing subset of rows,
  3. after than outer rows are appended with NULLs on inner table's joined columns,
  4. on that result the WHERE clause is applied performing filtering.

When you place the condition within WHERE clause which touches outer tables rows they're all discarded. You should simply place that condition within the ON clause, as that one is evaluated before outer rows are appended.

So, those conditions:

prescriptions.filldate >= '09-01-12' AND
prescriptions.filldate <= '09-17-12'

should be moved into ON clause.