强制 SQL Reporting Services 2005 表显示一定数量的行

发布于 2024-08-09 08:51:35 字数 215 浏览 3 评论 0原文

我有一份 SQL Reporting Services 2005 报告,其中第一页上有一个表。我在首页上有足够的空间来显示列表中的前 5 项。如果项目超过 5 个,我希望列表继续到报告第二页上的另一个表格。

我还希望表具有固定的行数。例如,即使列表中不存在任何项目,第一页上的表也始终显示 5 行。这使得边框仍然可见,这样页面布局就不会混乱。

关于让它发挥作用的最佳方法有什么想法吗?

I've got a SQL Reporting Services 2005 report that includes a table on the first page. I have enough room on the first page to show the first 5 items from a list. If there are more than 5 items, I want the list to continue to another table on the second page of the report.

I also want the tables to have a fixed number of rows. For example, the table on the first page always shows 5 rows even if no items exist in the list. This allows the border to still be visible so that the page layout isn't messed up.

Any thoughts on the best way to get this working?

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

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

发布评论

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

评论(4

北城半夏 2024-08-16 08:51:35

我认为这最好在返回数据的查询/存储过程中完成,而不是在 SSRS 中。

您可以执行类似这样的操作

SELECT TOP 5 FROM
(
    SELECT Top 5 *
    FROM DummyOrBlankDataFillerView
    UNION
    SELECT TOP 5 *, Row_Number() over (order by YourColumns) as OrderByClause 
    FROM ActualQueryThatBringsBackRecords
)
ORDER BY OrderByClause

OrderByClause 按您的列排序,并且将具有 (1,2,3,4,5) 并且 DummyOrBlankDataFillerView 应该具有您返回的列,该列在同一列中具有值如 (6, 7, 8, 9, 10)。

然后,在 order by 和“top 5”之间,您应该拥有需要显示的内容。

I think that this is best done in the Query / Stored Proc that returns the data rather than in SSRS.

You can do something like this

SELECT TOP 5 FROM
(
    SELECT Top 5 *
    FROM DummyOrBlankDataFillerView
    UNION
    SELECT TOP 5 *, Row_Number() over (order by YourColumns) as OrderByClause 
    FROM ActualQueryThatBringsBackRecords
)
ORDER BY OrderByClause

OrderByClause is ordered by your columns and will have (1,2,3,4,5) and DummyOrBlankDataFillerView should have a column that you get back that has values in the same column as (6, 7, 8, 9, 10).

Then, between the order by, and the `top 5' you should have what you need to display.

猫九 2024-08-16 08:51:35

我认为没有一个简单的方法可以做到这一点。 AFAIK,SSRS 不会在这里帮助你。您可以更改查询逻辑,以便在返回的实际行数 < 时用许多“虚拟”行填充结果集。 5. 然而,这似乎是一个混乱的解决方案。

I don't think there's an easy way to do this. AFAIK, SSRS won't help you here. You could change your query logic so that it pads out the resultset with a number of 'dummy' rows if the actual number of rows returned is < 5. However this seems like a messy solution.

相思故 2024-08-16 08:51:35

可能不完全是您正在寻找的答案,但您可以将第一个表绑定到的查询或数据源限制为 5 个项目或其他。然后,第二个表将绑定到仅包含剩余项目的查询或数据源。

我认为报告中没有办法对财产或类似的东西做到这一点。

Probably not exactly the answer you are looking for but you could limit the query or data source the first table is bound to to 5 items or whatever. Then the second table would be bound to a query or data source with just the remaining items.

I don't think there is a way in the report to do this with a property or anything like that.

一花一树开 2024-08-16 08:51:35

当没有空白数据时,您将需要合并一些空白数据。

例如,将计算行添加到名为 rowcount 的数据集

=rownumber("datasetname")

然后过滤第一个表的 rowcount < 6

You will need to union in some blank data when there is none.

Add a calculated row to the dataset called rowcount for example

=rownumber("datasetname")

Then filter the first table for rowcount < 6

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