Pakard
Pakard

Reputation: 39

Concatenates the values of string expressions in azure synapse serverless pool

I would like to write a query in serverless pool for concatenation of string values from multiple rows into single row with comma separated values. I am getting below error when I use COALESE function which I am unable to fix "Queries referencing variables are not supported in distributed processing mode"

Input rows : A B C A B Output row (Looking for distinct values only while creating a list like below) A,B,C

Upvotes: 1

Views: 1561

Answers (1)

NiharikaMoola
NiharikaMoola

Reputation: 5074

You can use STRING_AGG() function to concatenate values from multiple rows to a single row with comma-separated.

Get distinct values of a column and apply STRING_AGG on the results as below.

select STRING_AGG(col1, ',') output_col1 from (select distinct col1 from #tb1) a

enter image description here

Upvotes: 0

Related Questions