Listagg alternative in db2
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
...
DB2 SQL: Grouping records with same id in result?
give this a try,
SELECT ID,
SUBSTR(xmlserialize(xmlagg(xmltext(CONCAT( ', ',text))) as VARCHAR(1024)), 3)
FROM tableName
GROUP BY ID;
Create a delimitted string from a query in DB2
I'm trying to do this in OLEDB and from what I understand you can't do this because you can't do anything fancy in SQL for OLEDB like declare variables or create a table. So I guess there is no way.
Related Topics
How to Check the Query Is Using Index
Is Order by and Row_Number() Deterministic
MySQL Is Array in Multiple Columns
What Does It Mean to Have Jobs with a Null Stop Date
Unique Constraint Controlled by a Bit Column
Ms SQL Server Last Inserted Id
What's the Asymptotic Complexity of Groupby Operation
Selecting Top N Elements of a Group in Oracle
Convert Row Data to Column in SQL Server
SQL Server - Dirty Reads Pros & Cons
SQL Joins: Future of the SQL Ansi Standard (Where VS Join)
Login Failed. the Login Is from an Untrusted Domain and Cannot Be Used with Windows Authentication
Postgres Query of an Array Using Like