我正在使用SSRS 2012,其中我正在开发一个矩阵类型的报告。用户指定他想要在报告中显示的类别(行标题)和城市(列标题),我们已经通过传递参数进行了处理。
报告中的值是在应用我们在存储过程中处理的一些公式后出现的。
我被卡住了,因为我需要在页脚中显示每个城市下的排名。排名取决于与城市相关的所有类别的值的总和。
示例:
City-1 City-2 City-3
Cat-1 50 20 40
Cat-2 10 30 40
==============================
Rank 2 3 1发布于 2016-04-11 08:49:04
查询:
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.CitySSRS表设计:

结果:

https://stackoverflow.com/questions/36446222
复制相似问题