MS 报表设计器 - 什么是表组以及它们如何使用?

发布于 2024-09-08 05:03:12 字数 399 浏览 5 评论 0原文

我正在使用 Reporting Services 2000/2005 和带有内置报表设计器的 Visual Studio 2005 来处理一些现有 MS 报表的项目。

我遇到过一个报告,它使用表格来显示由存储过程获取的数据。我的工作要求我修改报告和存储的过程。

我已经对存储过程进行了更改,并且在 SQL Management Studio 中测试时它返回了正确的数据。然而,在报告中,尽管我使用完全相同的参数,但由于某种原因缺少一些数据。

我有一种偷偷摸摸的感觉,这与为报告主表定义的表组有关。该表定义了 2 个表组。我删除了第二个表组中的一些项目,因为它们已从存储过程和报告中删除。也许我需要将存储过程中的新字段/列添加到表组中?

任何人都可以为我指明如何调查/解决此问题的正确方向,以及表组是什么以及如何使用它们。

I am working on a project with some existing MS Reports using Reporting Services 2000/2005 and Visual Studio 2005 with the built in Report Designer.

I have come across a report that makes use of a table to display data which is fetched by a Stored Proc. My work required me to modify the report and the stored Proc.

I've made the changes to the stored proc, and it returns the correct data when tested in SQL Management Studio. However, in the report, some of the data is missing for reason, even though I am using the exact same parameters.

I have a sneaky feeling that it has to do with Table Groups defined for the main table of the report. The table has 2 table groups defined. I deleted some of the items in the 2nd Table Group, as they were removed from the stored proc and report. Perhaps I need to add the new fields/columns from the stored proc to the table group?

Can anyone point me in the right direction on how to investigate/solve this problem, and also what table groups are, and how they are meant to be used.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流年里的时光 2024-09-15 05:03:12

表中的组的工作方式与 SQL 查询中的组类似 - 每个组中的数据仅返回一次,而不是每个记录返回一次。但是,由于您还可以在表中包含详细信息行,因此您还可以从单个报告表中查看组级别和详细信息级别数据,而这需要在 SQL 中进行单独的(子)查询。

作为示例,考虑 SQL 中的销售结构:

sales_month
sales_day
sales_product
sales_value

您可以使用查询在 SQL 中返回按日期顺序排列的所有销售的列表

select * from sales order by sales_month, sales_day;

或者您可以使用查询在 SQL 中按月返回所有销售的摘要

select sales_month, sum(sales_value) as monthly_sales 
from sales group by sales_month order by 1;

通过使用分组的报表月,通过详细信息行和组页脚,您可以按日期顺序列出所有销售额,并在每个月末列出每个月的小计。

SSRS 帮助中有一些教程说明了如何在报表中使用分组。

Groups in tables work in a similar way to groups in a SQL query - data in them is only returned once per group, instead of once per record. However, because you can also include details rows in a table, you can also see both group level and detail level data from a single report table, whereas this would require separate (sub)queries in SQL.

As an example, consider a sales structure in SQL:

sales_month
sales_day
sales_product
sales_value

You could return a list of all sales in date order in SQL with the query

select * from sales order by sales_month, sales_day;

Or you could return a summary of all sales by month in SQL with the query

select sales_month, sum(sales_value) as monthly_sales 
from sales group by sales_month order by 1;

By using a report table grouped on month, with detail rows and a group footer, you could list all sales in date order with a subtotal for each month, at the end of each month.

There are tutorials within the SSRS help that illustrate the use of grouping within a report.

余生再见 2024-09-15 05:03:12

好的,所以我将存储过程中的新列添加到表组中,并且它按预期工作。

我认为通过在表组中省略几列,报告会在更少的字段上进行分组,这意味着这些行都被视为相同的值。

当我一次添加一个新字段来匹配存储过程中的字段时,报告的准确性就越高。

我认为这类似于 SQL 要求 Select 子句中的每个字段也出现在 Group By 子句中。

Ok, so I added the new columns in the stored proc to the table group, and it is working as expected.

I think by ommitting a few columns in the table group, the report was grouping on fewer fields, meaning that these rows were all seen to be the same value.

As I added one new field at a time to match the fields in the stored proc, the better the accuracy of the report became.

I think it is similar to how SQL requires that every field in the Select clause also appear in the Group By Clause.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文