title: SQL how can I have sql return one row instead of multiple per distinct ID?
body: <p>According to my coworker, We are using IBM DB2</p>
  
  <p>Having real hard time trying to make my sql return one row per ID.  Asked around at work but no girl here are good with SQL...  I can do some sql but am no SQL expert.</p>
  
  <p>To explain it better, I set up the example below</p>
  
  <p>Here is the TABLE and its data</p>
  
  <pre><code>ID  DATE        CODE  PERCENT
  01  2016-08-21  1111  52
  01  2016-09-06  1111  60
  01  2016-10-06  1112  38
  02  2016-05-01  6666  50
  02  2016-10-01  1111  50
  </code></pre>
  
  <p>I want one record returned per each ID with earliest DATE.
  so I wrote below SQL</p>
  
  <pre><code>SELECT ID, MIN(DATE) 
  FROM TABLE
  WHERE DATE &gt;= '2016-01-01' AND  DATE &lt;= '2017-11-01'
  AND   CODE = 1111
  GROUP BY ID
  </code></pre>
  
  <p>that worked fine.  I would get </p>
  
  <pre><code>01 2016-08-21
  02 2016-10-01
  </code></pre>
  
  <p>I soon realized that I also need PERCENT column.</p>
  
  <pre><code>SELECT ID, MIN(DATE), PERCENT
  FROM TABLE
  WHERE DATE &gt;= '2016-01-01' AND  DATE &lt;= '2017-11-01'
  AND   CODE = 1111
  GROUP BY ID, PERCENT
  </code></pre>
  
  <p>but now, I'm getting the multiple rows for ID 01 which is wrong...</p>
  
  <pre><code>01  2016-08-21  1111  52
  01  2016-09-06  1111  60
  02  2016-10-01  1111  50
  </code></pre>
  
  <p>Can somebody help me fix this SQL or point me to the right direction so that I can have one row per ID like below?</p>
  
  <pre><code>01  2016-08-21  1111  52
  02  2016-10-01  1111  50
  </code></pre>