结合和逗号分开的行

问题描述 投票:0回答:1

我有这个问题:

SELECT
    c.br,
    c.no_,
    CONCAT(c.name, ' ', c.surname) AS Name,
    t.type,
    t.code,
    t.sub,
    GETDATE() AS date,
    c2.name 
FROM
    c 
    INNER JOIN t on c.rowno = t.rowno
    LEFT JOIN termjnt on t.rowno = termjnt.rowno
    LEFT JOIN c c2 on termjnt.rowno_c2 = c2.rowno
WHERE 
    t.status = 'active'

这是一个输出示例

enter image description here

如何为每个no_组合c2.name行?例如,我不希望Heather和Humphry成为不同的行,而是希望单元格成为“Humphry,Heather”

sql-server-2016
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.