将多行转换为一列

时间:2021-11-08 01:36:00

I would like to take the data output from the query below and join all of the email addresses together separated by a semicolon grouped by the employee name.

我想从下面的查询中获取数据输出,并将所有电子邮件地址连接在一起,用一个分号分隔,每个分号按员工名分组。

SELECT
    DISTINCT
    p.email
    , e.name 
FROM
    PERSON p
INNER JOIN 
    EMPLOYEE e
ON 
    p.agentofrecord_id = e.employee_id 
WHERE 
    dbo.GetPersonMember(p.person_id) = 1
    AND (p.isactive = 1)
    AND p.email <> ''
ORDER BY name

1 个解决方案

#1


5  

Basically, it looks like you want MySql's GROUP_CONCAT aggregate function in TSQL. If that's the case, this article may help -- check it out!

基本上,看起来您希望在TSQL中使用MySql的GROUP_CONCAT聚合函数。如果是这样的话,这篇文章可能会有所帮助——看看吧!

#1


5  

Basically, it looks like you want MySql's GROUP_CONCAT aggregate function in TSQL. If that's the case, this article may help -- check it out!

基本上,看起来您希望在TSQL中使用MySql的GROUP_CONCAT聚合函数。如果是这样的话,这篇文章可能会有所帮助——看看吧!