SQL - multiple rows in one column

I would like to extract the data from the query below and combine all the email addresses, separated by a semicolon, grouped by 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
+3
source share
1 answer

Basically, it looks like you want the MySql GROUP_CONCATaggregate function in TSQL. If this case, this article may help - check it out!

+5
source

Source: https://habr.com/ru/post/1710739/


All Articles