title: SQL MIN(value) matching row in PostgreSQL 2
body: <p>I have a following table:</p>
  
  <pre><code>  ID          ID NAME      PRICE        DATE             CODE
   00003          E           2000      2018/03/24        null        
   00001          C           3000      2018/03/22         1   
   00001          D           4000      2018/03/23         1  
   00002          F           1000      2018/03/21         2   
   00005          B           1000      2018/03/21         2  
   00004          A           2000      2018/03/24        null  
  </code></pre>
  
  <p>I want to group by CODE with min(ID) and get ID NAME match up with the min row value
  If have same ID, get ID NAME which Min(DATE)
  If the CODE is null, I don't want to group</p>
  
  <p>I would like the query to return the following</p>
  
  <pre><code> ID         ID NAME     PRICE       
  00001         C         7000
  00002         F         2000
  00003         E         2000
  00004         A         2000
  </code></pre>
  
  <p>What SQL can I use to get that result?</p>