我有这种形式的数据(同一个人的多个AUTHCD)
PERSNBR AUTHCD VALUE File# Payroll Name Reports To File# Reports To Name
3533 CSR2 5874 109605 Burnette, Peter M 105874 Vo, Timothy
3533 DOPS 5874 109605 Burnette, Peter M 105874 Vo, Timothy
3533 IT03 5874 109605 Burnette, Peter M 105874 Vo, Timothy
3533 LSUP 5874 109605 Burnette, Peter M 105874 Vo, Timothy
3533 OSUP 5874 109605 Burnette, Peter M 105874 Vo, Timothy
但我希望我的数据显示如下:
PERSNBR AUTHCD VALUE File# Payroll Name Reports To File# Reports To Name
3533 CSR2, DOPS, IT03, LSUP 5874 109605 Burnette, Peter M 105874 Vo, Timothy
我希望列AUTHCD显示的原因是因为当我使用示例数据并创建SSRS报告时,它只显示第一个AUTHCD并切断其余部分,而我想要该员工的所有auth代码。 我应该用SSRS或sql代码吗? 这是我的代码:
select pa.PERSNBR
,pa.AUTHCD
,pu.VALUE
,File#, [Payroll Name]
, [Reports To File#], [Reports To Name]
, [EMC #], [EMC Name]
, 1 as level
from
[DNA_Staging].[dbo].[PERSAUTH] pa
join [DNA_Staging].[dbo].[PERSEMPL] pe
on pa.PERSNBR = pe.PERSNBR
join [DNA_Staging].[dbo].[PERSUSERFIELD] pu
on pe.PERSNBR = pu.PERSNBR
and pu.USERFIELDCD = 'EFNR'
and GETDATE() < isnull(pe.inactivedate,getdate()+1)
join [HR_Staging].[dbo].[HR_EmployeeHierarchyStaging] emp
on pu.VALUE = substring(emp.[Reports To File#],2,6)
or pu.VALUE = substring(emp.[Reports To File#],3,6)
where [Reports To File#] = @ReportToFile
提前致谢!