We help IT Professionals succeed at work.

question about regrouping the rows

68 Views
Last Modified: 2017-04-29
hi all,

I have a similar issue posted here, but not exactly the same.

I have a table
emp_dept
(emp_id numeric,
dept_id numeric,
department char(3) )

employees
(emp_id numeric,
 emp_name varchar(100)
)

1: 1 employee can belong to 2 different departments
2: I want the output like
emp id, emp_name, (list of all departments the emp_id belongs to )--separated by comma)

this is for displaying, I know we can use a temp table etc to do this, but was looking for any better approach.
Comment
Watch Question

EE Topic Advisor
CERTIFIED EXPERT
Most Valuable Expert 2014
Awarded 2013
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION