title: SQL Joining three tables and using LEFT OUTER JOIN
body: <p>I have three tables and  two seperate SQL queries which are working correctly and I am having correct results.
  If I try to join these three tables I am having null as result.</p>
  
  <p>First query:</p>
  
  <pre><code>select T1.ID,T3.COMPANY
  from T1,T3
  where (T1.status!='CLOSED') and (T1.PRIORITY)&gt;5 and T1.CLASSID=T3.CLASSID
  </code></pre>
  
  <p>Second query:</p>
  
  <pre><code>SELECT T1.ID, T2.DESCRIPTION 
  FROM T1
  LEFT OUTER JOIN T2
  ON T1.ID=T2.KEY 
  WHERE    T1.status!='CLOSED' 
  AND (T2.CREATEDATE= (SELECT MAX(CREATEDATE) 
  FROM T2
  WHERE  T2.KEY=T1.ID))
  </code></pre>
  
  <p>I tried to join them but as result I am having <strong>null</strong>:</p>
  
  <pre><code>select T1.ID,T3.COMPANY,T2.DESCRIPTION 
  from T1
  INNER JOIN T3 ON T1.CLASSID=T3.CLASSID
  LEFT OUTER JOIN  T2
  ON T1.ID=T2.KEY 
   where (T1.status!='CLOSED') AND  (T1.PRIORITY)&gt;5
  AND (T2.CREATEDATE= (SELECT MAX(CREATEDATE) 
  FROM T2
  WHERE T2.KEY=T1.ID))
  </code></pre>
  
  <p>like it does not recognized last part for taking MAX value from T2 table.</p>
  
  <p>What am I doing wrong? Thanks for help</p>