【问题标题】:Result set with multiplied rows into an SSRS reportSSRS 报告中包含相乘行的结果集
【发布时间】:2013-04-15 23:54:53
【问题描述】:

我需要将此查询放入 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 结束时完成吗?

【问题讨论】:

    标签: sql tsql reporting-services ssrs-2008


    【解决方案1】:

    是的,您可以通过添加 tablix 来实现:

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

    你会得到这样的结果:

    【讨论】:

    • 这是一个很好的解决方案,唯一的问题是如果他有多个SR_RecID,我认为是这样。因为你需要把SR_RecID作为一个外部组,你可以在里面添加DescriptionNotes
    • 是的,在这种情况下你是对的,但在问题时刻,输出格式对我来说并不完全清楚。
    • 这很好用。非常感谢!作为记录,它是多个 SR_RecID,所以我创建了外部组。
    猜你喜欢
    • 2022-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-20
    相关资源
    最近更新 更多