title: DB2 query to fetch first value in a group
body: <p>I have a db2 query which has to fetch the first value present for a column(Col6). I have tried using minimum for the column, but it fetches the first value in ascending order. </p>
  
  <p>The table is as follows:</p>
  
  <pre><code>Col1    Col2    Col3    Col4    Col5    Col6
  10      -1      N/A     1       41      Pack Inv
  10      -1      N/A     1       10      Fl Sales
  10      -1      N/A     1       10      St Ss Bu
  10      -1      N/A     1       41      Pack Inv
  </code></pre>
  
  <p>The expected output for Col7 is as follows:</p>
  
  <pre><code>Col1    Col2    Col3    Col4    Col5    Col6        Col7
  10      -1      N/A     1       41      Pack Inv    Pack Inv
  10      -1      N/A     1       10      Fl Sales    Pack Inv
  10      -1      N/A     1       10      St Ss Bu    Pack Inv
  10      -1      N/A     1       41      Pack Inv    Pack Inv
  </code></pre>
  
  <p>By using MIN(Col6) OVER (PARTITION BY Col1) AS "Col7",the output generated is:</p>
  
  <pre><code>Col1    Col2    Col3    Col4    Col5    Col6        Col7
  10      -1      N/A     1       41      Pack Inv    Fl Sales
  10      -1      N/A     1       10      Fl Sales    Fl Sales
  10      -1      N/A     1       10      St Ss Bu    Fl Sales
  10      -1      N/A     1       41      Pack Inv    Fl Sales
  </code></pre>
  
  <p>May I know how the expected output can be achieved in db2.</p>
  
  <p>Thank you</p>