HP.
HP.

Reputation: 19896

Group by a column but concat another column with comma delimited

I have a table with company_name and RegistrationId column.

How to write a query so that I can do group by company_name but concatenate all values of RegistrationId into a string column (say AllIDs) with comma like 123,456,789?

Upvotes: 2

Views: 2579

Answers (1)

Alexander Sloutsky
Alexander Sloutsky

Reputation: 3017

This can be expressed as:

T | summarize AllIds=make_list(RegistrationId) by company_name

You can use make_set() function to create unique set (without repetitions of ids).

https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/makelist-aggfunction https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/makeset-aggfunction

If you need later to format a string from array - use strcat_array() function:

https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/strcat-arrayfunction

Upvotes: 3

Related Questions