I have an EMPLOYEE table that references the roles assigned to an employee, and the skills the employee has. I am trying create a SELECT statement using SQL Server that will return, per row, the Employee #, Employee Login, Employee Name, Facility, Work Center, Roles and Skills. The roles are referenced in another table as are the skills.
My issue is that I cannot seem to write a SQL query such that an employee with multiple roles and/or skills would have each skill listed per employee record.
My current SQL only retrieves one role/skill per row.
SELECT 
    e.EmployeeNo, e.Name, e.LoginName, f.Facility, w.WorkCenter, 
    r.Role AS Roles, s.Name as Skills
FROM
    EMPLOYEE e
LEFT JOIN 
    EMPLOYEE_FACILITY f ON e.ID = f.EmployeeID
LEFT JOIN 
    EMPLOYEE_WORK_CENTER w ON e.ID = w.EmployeeID
JOIN 
    EMPLOYEE_ROLE er ON e.ID = er.EmployeeID
LEFT JOIN 
    ROLE r ON er.ID = r.ID
JOIN 
    EMPLOYEE_SKILL es ON e.ID = es.EmployeeID
LEFT JOIN 
    SKILL s ON es.ID = s.ID
GROUP BY
    e.EmployeeNo, e.Name, e.LoginName, f.Facility, w.WorkCenter, 
    r.Role, s.Name
ORDER BY
    e.EmployeeNo
The output I'm looking for is:
| Employee # | Employee Name | loginName | Facility | WorkCenter | Roles | Skills | 
|---|---|---|---|---|---|---|
| 123456789 | Test | TestLogin | ABC1 | MACHINING | IT | CPP | 
| ADMIN | SCRUM | |||||
| 234567890 | TestUser | Test2 | DEF2 | STAMPING | FAB | LABOR | 
 As you can see, I'm getting multiple rows for each Employee #, I'm trying to combine all the roles and skills for a given employee into a single row.
As you can see, I'm getting multiple rows for each Employee #, I'm trying to combine all the roles and skills for a given employee into a single row.
EDIT: Is it possible to combine the rows with JOINs? I am rather rusty in SQL, and the last time I used MySQL was years ago.
 
    