Search notes:

SQL Server: string_agg

string_agg is SQL Server's implementation of the SQL standard feature T625 (listagg). It is available from version 2017.
drop table if exists ##tq84_items;

create table ##tq84_items (
   grp  integer,
   txt  varchar(10)
);

insert into ##tq84_items values (1, 'foo');
insert into ##tq84_items values (1, 'bar');
insert into ##tq84_items values (1, 'baz');

insert into ##tq84_items values (2, 'grapefruit');
insert into ##tq84_items values (2, 'banana');

select
   grp,
   string_agg(txt, ' - ') items
from
   ##tq84_items
group by
   grp;
--
-- grp         items
-- ----------- -------------------
-- 1           foo - bar - baz
-- 2           grapefruit - banana


select
   grp,
   string_agg(txt, ' - ') within group (order by txt) ordered_items
from
   ##tq84_items
group by
   grp;
--
-- grp         ordered_items
-- ----------- -------------------
-- 1           bar - baz - foo
-- 2           banana - grapefruit
Github repository about-MSSQL, path: /sql/select/group-by/string_agg/simple.sql

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758210040, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/SQL-Server/sql/select/group-by/string_agg/index(75): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78