按聚合列分组和排序

时间:2016-08-01 10:24:56

标签: reporting-services

我正在创建SSRS报告并拥有以下数据集。

ID       City      Country
------------------------------
1       London     England
2       Glasgow    Scotland
3       Aberdeen   Scotland
4       Swansea    Wales
5       London     England
6       Glasgow    Scotland
7       Glasgow    Scotland
8       Manchester England  

我在' City'上有COUNT。并按城市和国家分组。这就是我希望它出现的方式

City              Country              Total
--------------------------------------------
Glasgow           Scotland               3
London            England                2  
Swansea           Wales                  1
Aberdeen          Scotland               1
Manchester        England                1

然而,这就是它出现的方式

City               Country             Total
--------------------------------------------    
Swansea           Wales                  1
Glasgow           Scotland               3
                                         3
                                         3
Aberdeen          Scotland               1
Manchester        England                1
London            England                2
                                         2

因此,我需要按总计列进行分组,并按该列排序,但不确定如何执行此操作。感谢所有人的帮助。

在下面尝试过桑杰斯答案,除非我做错了我得到了这个错误。

enter image description here

2 个答案:

答案 0 :(得分:1)

这里 我们需要创建城市和国家/地区,并从行组中删除详细信息部分,如下所示

enter image description here

所以表格看起来像上面的变化

enter image description here

并为第一组city1设置 Count(Fields!ID.Value," CITY") sd排序表达式,订单Z为A

enter image description here

答案 1 :(得分:1)

你可以通过多种方式解决这个问题。一种选择是处理查询中的分组并简单地在SSRS中显示结果。所以你的查询看起来像这样:

SELECT ID, City, Country, COUNT(*) as Total
FROM MyTable
GROUP BY ID, City, Country

现在,在SSRS中,您可以按Total列进行排序,因为它未在报告中汇总。

相关问题