cancel
Showing results for 
Search instead for 
Did you mean: 

Select a comma delimited list from table column

robert_shandley
Explorer
0 Kudos

Hi,

I have a table with two columns. CustomerID and AccountManager.

Most customers have just one account manager. Some have two or more.

I need to query the table, returning one row per CustomerID, with the AccountManager. For the customers with more than one account manager, I need to return a comma separated list of account managers.

e.g.

Customer table:

Query result:

I need the query result as a view for further use.

Can anyone give me a tip, without using a Cursor?

Thanks in advance,

Rob

Accepted Solutions (1)

Accepted Solutions (1)

former_member182302
Active Contributor
0 Kudos

You can use STRING_AGG to achieve this

SAP HANA Academy - SQL Functions: String_Agg - YouTube

Regards,

Krishna Tangudu

robert_shandley
Explorer
0 Kudos

Many thanks Krishna.

That looks about right. I'll try it on Monday and reply.

Regards

Rob Shandley

robert_shandley
Explorer
0 Kudos

Thanks again Krishna.

That did the trick

Regards

Rob Shandley

Answers (0)