The below code works fine. It displays the column orgid in a single row. But when I remove the group by clause from the code, it shows output "NULL". I wonder why and how group by clause affects the output.
declare @orgname varchar(max)
select @orgname = coalesce(@orgname,'') + orgid + ','
from org group by orgid