Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL - Multiple rows into single column

Tags:

sql

t-sql

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
like image 274
RSolberg Avatar asked Jun 08 '26 12:06

RSolberg


1 Answers

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!

like image 121
Alex Martelli Avatar answered Jun 11 '26 02:06

Alex Martelli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!