SELECT *
FROM (
select PeopleSoft.[Common Name],Role.Role
FROM eng_kpi.tbl_Projectx_EC_Action as EC_Action
Left outer join eng_kpi.tbl_ProjectX_EC_Assignments as EC_Assignments on EC_Assignments.EC_Number=EC_Action.EC_ID and EC_Assignments.Role_ID between 160 and 165
left outer join eng_kpi.tbl_ProjectX_Role as Role on Role.Role_ID = EC_Assignments.Role_ID
Left outer join eng_kpi.PeopleSoft as PeopleSoft on [Emp Num]= EC_Assignments.[User_ID]
where EC_ID=174391 and Workflow_ID=257 and Date_Completed is null and Date_Cancelled is null and Date_Started is not null
) as DataTable
PIVOT
(
[Common Name] for [role] in ('Austin OPS Level 1','Austin OPS Level 2','Austin OPS Level 3','Austin Finance Level 1','Austin Finance Level 2','Austin Finance Level 3')
)
SELECT *
FROM (
select PeopleSoft.[