title: SQL concatenate rows into one field (DB2)
body: <p>I need to extract some data from my DB2 database. I have keywords in one table and each keyword is a separate row. In the extract I want to have all keywords for all IDs in one string separated by a comma.</p>
  
  <p>So, to explain:
  I have such data</p>
  
  <pre><code>ID         | keyword 
  ===========================
  prd1       | test
  ---------------------------
  prd2       | keywords
  ---------------------------
  prd1       | flower
  ---------------------------
  prd4       | picture
  ---------------------------
  prd7       | 234567
  ---------------------------
  prd9       | reored
  ---------------------------
  prd4       | finland
  ---------------------------
  prd0       | 983y23
  ---------------------------
  prd4       | code
  ---------------------------
  prd9       | tratata
  </code></pre>
  
  <p>And here is a sample of what I want to achieve:</p>
  
  <pre><code>ID         | keyword concatenated
  ===========================
  prd1       | test, flower
  ---------------------------
  prd2       | keywords
  ---------------------------
  prd4       | picture, finland, code
  ---------------------------
  prd7       | 234567
  ---------------------------
  prd9       | reored, tratata
  ---------------------------
  prd0       | 983y23
  ---------------------------
  </code></pre>
  
  <p>I tried with <code>concat</code>:</p>
  
  <pre><code>SELECT concat(keyword) FROM table.keywordTbl
  </code></pre>
  
  <p>I tried with some DB2 specific commands:</p>
  
  <pre><code>SELECT IDs, Sys_Connect_By_Path(varchar(keyword), ', ') AS "keyword concatenated" FROM table.keywordTbl START WITH ID='prd1' CONNECT BY ID=keyword
  </code></pre>
  
  <p><code>PIVOT</code> is not right for this, but I have checked it too.
  <code>GROUP_CONCAT</code> is not working either.</p>
  
  <p>Of course, none of these work...</p>
  
  <p>Do you have any hints for me?</p>