sql - ListAGG in SQLSERVER -


i'm trying aggregate 'string' field in sqlserver. find same function listagg in oracle .

do know how same function or method?

for example,

field | field b 1       |  1       |  b 2       |  

and result of query

1 | ab 2 | 

in sql server can use for xml path result:

select distinct t1.fielda,   stuff((select distinct '' + t2.fieldb          yourtable t2          t1.fielda = t2.fielda             xml path(''), type             ).value('.', 'nvarchar(max)')          ,1,0,'') data yourtable t1; 

see sql fiddle demo


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -