title: Oracle SQL - left join + left outer join
body: <p>I am querying three tables. TABLE1 A and TABLE2 B have a one-to-one ratio on DEPTID. TABLE3 C, however, does not hold 0 values. I can successfully get COUNT to give me 0 values from TABLE3 C when doing a LEFT OUTER JOIN with TABLE1 A or TABLE2 B, but it gives me (null) instead of 0 when I join all three tables together. I need it to return 0 instead of (null). Any help is very much appreciated:</p>
  
  <pre><code>SELECT A.DEPTID, B.DEPT_NAME, SUM(C.HEAD_COUNT)
  FROM TABLE1 A
  LEFT JOIN TABLE2 B ON A.DEPTID = B.DEPTID
  LEFT OUTER JOIN TABLE3 C ON A.POSITION_NUMBER = C.POSITION_NUMBER
  GROUP BY A.DEPTID, B.DEPT_NAME
  </code></pre>
  
  <p>Here is what I am currently getting:</p>
  
  <p>Dept 1: headcount 9<br>
  Dept 2: headcount 11<br>
  Dept 3: (null)</p>