结果集将乘法行放入SSRS报告中

时间:2013-04-15 23:54:53

标签: sql tsql reporting-services ssrs-2008

我需要将此查询纳入SSRS报告。

SELECT  s.SR_Service_RecID    -- will have 1 result
     ,  p.Description         -- will have 8 results 
     ,  t.notes               -- will have 5 results

FROM SR_Service s
     LEFT JOIN IV_Product p
            ON p.SR_Service_RecID = s.SR_Service_RecID
     LEFT JOIN Time_Entry t
            ON t.SR_Service_RecID = s.SR_Service_RecID

此查询将p.Description与t.Notes相乘,以获得预期的总行数。

结果集:

SR_RecID    Description    Notes
12345       Product 1      Note 1
12345       Product 1      Note 2
12345       Product 1      Note 3
12345       Product 1      Note 4
12345       Product 1      Note 5
12345       Product 2      Note 1
12345       Product 2      Note 2
12345       Product 2      Note 3
12345       Product 2      Note 4
12345       Product 2      Note 5
Etc..

如何将其纳入SSRS报告中,以便仅显示实际结果,而不是相乘的数量?

SR_RecID
12345

Description
Product 1
Product 2
Product 3
Product 4
Product 5
Product 6
Product 7
Product 8

Notes 1
Notes 2
Notes 3
Notes 4
Notes 5

我是否需要重新编写查询,还是可以在SSRS结束时完成?

1 个答案:

答案 0 :(得分:2)

是的,您可以通过添加tablix来实现这一目标:

image1

并使用3个相邻的组(按每个字段分组),如下所示:

image2

你会得到这个结果:

image3