1

下面是我的sql查询

USE AdventureWorks2012

Select EDH.*, 
case when EDH.DepartmentID between 1 and 5 then 'DEPT-A'
when EDH.DepartmentID between 5 and 9 then 'DEPT-B'
when EDH.DepartmentID between 9 and 30 then 'DEPT-C' end as [DEPT TYPE]---, count(EDH.DepartmentID)
 from HumanResources.EmployeeDepartmentHistory EDH
left outer join HumanResources.Employee EM on EM.BusinessEntityID =  EDH.BusinessEntityID
group by EDH.DepartmentID, EDH.BusinessEntityID, EDH.ShiftID, EDH.StartDate, EDH.EndDate, EDH.ModifiedDate

我将 Dept Type 列作为 Dept-A、B 或 C 基于部门 ID 条件时的情况。

现在在 SSRS 报告中,我想在页脚中显示部门列的计数,例如

部门计数[A/B/C]:49/195/46

如何在报告中显示计数?我应该修改查询还是报告中需要一些更改

4

1 回答 1

2

您可以使用如下表达式:

="Dept Count [A/B/C]: "
  & Sum(IIf(Fields!DeptType.Value = "DEPT-A", 1, 0)) & "/"
  & Sum(IIf(Fields!DeptType.Value = "DEPT-B", 1, 0)) & "/"
  & Sum(IIf(Fields!DeptType.Value = "DEPT-C", 1, 0))

当您有一定数量的部门类型时,这将起作用。使用条件SumwithIIf来获取每个帐户中的数字。

适用于一些简化的数据:

在此处输入图像描述

于 2013-10-16T19:37:19.043 回答