Listagg alternative in db2

前端 未结 1 1577
渐次进展
渐次进展 2020-12-12 02:40

My customer is using db2 database without listagg function, but I need to somehow aggregate the primary key information within one field.

Right now (for Oracle) I am

相关标签:
1条回答
  • 2020-12-12 03:12

    If your version of DB2 supports pureXML (that would be at least DB2 for LUW 9.1 and I believe DB2 9 for z/OS), in addition to what @PM77-1 suggested above, you could use the XMLAGG function:

    select xmlserialize(
      xmlagg(
        xmlconcat(
          xmltext(column_name),
          xmltext(':'),
          xmltext(content),
          xmltext(',')
        )
      ) as varchar(10000)
    ) 
    from 
      yourtable 
    ...
    
    0 讨论(0)
提交回复
热议问题