SSRS 2008如何在列标题下对行数据进行分组

时间:2013-12-17 23:38:54

标签: sql-server sql-server-2008 reporting-services

我知道这很容易,但如果你不知道怎么回事。我正在尝试在SSRS 2008(而不是R2)中创建报告。

我的查询中返回了以下数据:

dept                quadrant        inv_quadrant    title    

Analgesics          High/High   High/High   Existing
Cough & Cold        High/High   High/High   Existing
Dispensary          High/High   High/High   Existing
First Aid & Wound   High/Low    Low/Low     Movement
Confectionary       Low/High    Low/High    Existing
Family Planning     Low/High    Low/High    Existing
Foot Care           Low/High    Low/Low     Movement
Medicines S2 & S3   Low/High    Low/High    Existing
Oral Hygiene        Low/High    Low/High    Existing
Stomach & Bowel     Low/High    Low/Low     Movement
Baby                Low/Low     Low/Low     Existing
First Aid & Wound   Low/Low     High/Low    New
Foot Care           Low/Low     Low/High    New

我希望数据按象限分组,然后按象限内的标题分组,如下所示:

High/High    Existing             Movement            New
             Analgesics
             Cough & Cold
             Dispensary
High/Low                          First Aid & Wound
Low/High     Confectionary        Foot Care
             Family Planning      Stomach & Bowel
             Medicines S2 & S3
             Oral Hygiene
Low/Low      Baby                                     First Aid & Wound
                                                      Foot Care

我几乎可以通过在象限上创建一个包含行组的表来呈现这样的内容,但是列中的数据是逐行显示的,而不是直接在其列标题下面显示,如下所示:

High/High    Existing             Movement            New
             Analgesics
             Cough & Cold
             Dispensary
High/Low                          First Aid & Wound
Low/High     Confectionary        
             Family Planning      
                                  Foot Care
             Medicines S2 & S3
             Oral Hygiene
                                  Stomach & Bowel

Low/Low      Baby
                                                      First Aid & Wound
                                                      Foot Care

我还尝试在标题上的象限和列组中使用带有行组的矩阵,但它只显示每个象限一个记录(??)...

我确定我需要某种列分组或基本的东西来解决这个问题。此外,查询是一个相当复杂的4个临时表的联合(讨厌,我没有写它)所以如果我可以避免使用我在类似情况下提到的dense_rank,我宁愿也不要乱用查询,除非没有其他办法。

非常感谢你!

1 个答案:

答案 0 :(得分:0)

好的,所以我想这会发生。事实证明我做了需要修改查询以包含DENSE_RANK ...

我添加了DENSE_RANK()OVER(PARTITION BY象限,标题ORDER BY jrdept_name)AS RNK然后将RNK添加到已经存在的Quadrant行分组中并且这样做了......

这被添加到原始解决方案的矩阵版本中,因此它已经将Title作为列分组。

在信用到期时给予信用我从这里得到答案:SSRS 2005 matrix not showing the data

谢谢!