title: How to get latest records for by records type in SQL
body: <p>My table looks like:</p>
  
  <pre><code>ID     NAME      TYPE      INSERTION_DATE      OCCURRANCE_DATE
  
  I100   ABC       WEEKLY    2019-12-31          2019-12-30
  I100   ABC       WEEKLY    2019-12-22          2019-12-20
  I101   DEF       MONTHLY   2019-12-31          2019-12-30
  I101   DEF       MONTHLY   2019-12-01          2019-11-29
  </code></pre>
  
  <p>How I can get latest records based on <code>OCCURANCE_DATE</code> for each type (Weekly &amp; monthly) using SQL query. The result should be like this:</p>
  
  <pre><code>ID     NAME      TYPE      INSERTION_DATE      OCCURRANCE_DATE
  
  I100   ABC       WEEKLY    2019-12-31          2019-12-30
  I101   DEF       MONTHLY   2019-12-31          2019-12-30
  </code></pre>