I am using SQL server 2017 and I have a scenario where I want to combine multiple rows of data into one row. Please see the below screenshot and let me know if that is possible. Thank you. Apologies if anything is missing.
Please let me know the query on how to achieve this
Advertisement
Answer
SQL Server has supported string_agg()
since 2017:
select employeeid, lastname, string_agg(projectname, ',') within group (order by projectname) as projectnames from t group by employeeid, lastname;