G
G
German Jet2020-09-04 15:06:02
SQL
German Jet, 2020-09-04 15:06:02

Is there an aggregate function in T-SQL to concatenate strings?

My query returns result like this:

Employee   PollNumber
------------    ----------
Alex      12        
Alex      13
Alex      14
Bob       15
Bob       16
Sam       17
I need to write a query that groups Employee together and displays a list of PollNumbers:
Employee    PollNumbers
------------    -----------
Alex      12, 13, 14
Bob       15, 16
Sam       17

For SQL 2017 there is STRING_AGG(), but I have a 2014 version, please tell me the query option

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lazy @BojackHorseman, 2020-09-04
@GeraJet

for xml
examples
Applies to: yesSQL Server (all supported versions)
from 2005 version. did not exist in 2000

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question