Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
427 views
in Technique[技术] by (71.8m points)

ksqldb - KSQL transform rows to column with GROUP BY

Have a stream column ID and Account numbers, would like to concatenate the Account# as comma separated list in one row.

Below is the query in SQL which creates the comma separated list with group by clause. (copy pasted from https://www.peteonsoftware.com/index.php/2009/12/11/creating-a-comma-separated-list-from-a-sql-grouping/)

    SELECT e.EmployeeId, e.FirstName, e.LastName,
    STUFF((SELECT ',' + COALESCE(LTRIM(RTRIM(t.TerritoryDescription)), '') 
    FROM EmployeeTerritories et
    INNER JOIN Territories t on et.TerritoryID = t.TerritoryID
    WHERE et.EmployeeID = e.EmployeeId
    FOR XML PATH('') ), 1, 1, '') as TerritoryList
    FROM Employees e

Is it possible to achieve in KSQL?

Please note the kafka connector is configured for the data source, and don't have much control on the source.

question from:https://stackoverflow.com/questions/66065887/ksql-transform-rows-to-column-with-group-by

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...