在树状结构SSRS中显示数据

时间:2016-09-19 12:49:55

标签: sql sql-server-2012 ssrs-2008 rdl

我有一个数据集,可以根据公司的级别提取公司的员工层次结构。查询使用如下:

;WITH DirectReports (ManagerID, EmployeeID, Level)
AS
(
SELECT [managerid] , e.EmployeeID, 
    0 AS Level
FROM Resource AS e
WHERE e.[managerid] is null and e.statecode=0
UNION ALL

SELECT e.[mtctb_resourcemanageridname], e.EmployeeID, Level +  1
FROM Resource AS e
INNER JOIN Resource AS d
    ON e.[managerid] = d.EmployeeID
    join DirectReports AS dr on  e.[managerid] = dr.EmployeeID
    where e.statecode=0
)

SELECT ManagerID, EmployeeID,  Level
FROM DirectReports 
WHERE EmployeeID is not null 


需要在报告中显示如下。enter image description here

0 个答案:

没有答案