I have this query:
SELECT DISTINCT
ces.CourseEventKey,
up.Firstname + ' ' + up.Lastname
FROM InstructorCourseEventSchedule ices
INNER JOIN CourseEventSchedule ces ON ces.CourseEventScheduleKey = ices.MemberKey
INNER JOIN UserProfile up ON up.UserKey = ices.UserKey
WHERE ces.CourseEventKey IN
(
SELECT CourseEventKey
FROM @CourseEvents
)
ORDER BY CourseEventKey
It produces this result set:
CourseEventKey Name
-------------- --------------------
30 JACK K. BACKER
30 JEFFREY C PHILIPPEIT
30 ROBERT B. WHITE
33 JEFFREY C PHILIPPEIT
33 KENNETH J. SIMCICH
35 JACK K. BACKER
35 KENNETH J. SIMCICH
76 KENNETH J. SIMCICH
90 BARRY CRANFILL
90 KENNETH J. SIMCICH
The data is accurate, but I need the result set to look like this:
CourseEventKey Name
-------------- --------------------
30 JACK K. BACKER; JEFFREY C PHILIPPEIT; ROBERT B. WHITE
33 JEFFREY C PHILIPPEIT; KENNETH J. SIMCICH
35 JACK K. BACKER; KENNETH J. SIMCICH
76 KENNETH J. SIMCICH
90 BARRY CRANFILL; KENNETH J. SIMCICH
I've seen questions like mine with working solutions, but I cannot for the life of me adapt those solutions to work with my data.
How can I change my query to produce the 2nd result set using some form of concatenation?
Thanks in advance.