Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

Analytics SQL Queries - Group multiple lines into comma separated

ArW
New Contributor III
New Contributor III

Hello,

Is it possible to use advanced SQL Function to group lines into comma separated values like XML PATH ('') or STRING_AGG ?

For instance, I have a dataset "Test_Customer" containing id and names
Id | Name
01 | Tata 
02| Toto
01 | Titi

The goal would be to obtain through an analytics a table that looks like this
Id | Names
01 | Tata, Titi
02| Toto

Is it possible ?

2 REPLIES 2

NM
Esteemed Contributor
Esteemed Contributor

Hi @ArW , use group_concat function.


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

GSR
Regular Contributor
Regular Contributor

try 

SELECT
Id,
GROUP_CONCAT(Name SEPARATOR ', ') AS Names
FROM
Test_Customer
GROUP BY
Id;