如何在SSRS页脚中显示排名

时间:2016-04-06 08:59:10

标签: reporting-services ssrs-2012

我正在使用SSRS 2012,其中我正在开发Matrix类型的报告。用户指定他希望在报告中显示哪些类别(行标题)和城市(列标题),我们通过将参数传递给报告来处理。

在应用我们在存储过程中处理的一些公式后,报告中的值出现。

我被困住了,我需要在每个城市的页脚下显示排名。排名取决于与城市相关的所有类别的值的总和。

示例:

       City-1  City-2  City-3  
Cat-1    50      20      40
Cat-2    10      30      40
==============================  
Rank      2       3       1

1 个答案:

答案 0 :(得分:0)

查询:

declare @tb as Table (City int,Cat int, Score int)
insert into @tb select 1,1,50
union select 1,2,10
union select 2,1,20
union select 2,2,30
union select 3,1,40
union select 3,2,40

select h.*,d.Rank from @tb h
inner join 
(select City,SUM(Score) as TotalScore,ROW_NUMBER() 
over (order by SUM(Score) desc) as Rank from @tb group by City ) d 
on h.City = d.City

SSRS表设计:

enter image description here

结果:

enter image description here