title: Select Missing date only if it is Maximum from a table in Oracle
body: <p>I have 2 tables. If table 1 has dates greater than table 2 only those record has should be populated in Output.</p>
  
  <p>Table 1:</p>
  
  <pre><code>ID Category Date
  1  A        3/2/1990
  1  A        3/5/2013
  1  C        4/3/1979
  2  D        4/3/1970
  2  D        5/6/2016
  3  E        8/8/2016
  </code></pre>
  
  <p>Table 2:</p>
  
  <pre><code>ID Category Date
  1   A       3/2/1990
  1   C       4/3/1979
  1   C       4/3/1982
  1   D       4/3/1982
  2   D       5/6/2016
  </code></pre>
  
  <p>The expected Output is</p>
  
  <pre><code>ID  Category Date
  1   A        3/5/2013
  3   E        8/8/2016
  </code></pre>
  
  <p>I tried the below query and its giving me incorrect results.</p>
  
  <pre><code>select a.id,a.category,a,Date from table1 a where
  a.Date &gt; (select Max(b.Date) from table2 b where a.id=b.id and a.category =b.catgory group by b.id,b.category)
  </code></pre>