如何显示双分组报告

发布于 2024-11-16 19:43:34 字数 1023 浏览 2 评论 0原文

假设我的 SQL 查询的结果是

Colour   size    week 1  week2  week 3


Black      x       1      2       3

white      xx      1      1       0

yellow     large   2      1       0

我想从这个查询中生成一个这样的报告。

               week 1               week 2              week 3
    ----------------------------------------------------------------
           x   xx   large       x   xx   large        x   xx   large
   ----------------------       --------------        -------------                                            
    black  1     0    0         2    0    0           3    0     0 

    white  1     0    0         0    1    0           0    0     0

    yellow 2     0    0         0    2    0           0    0     0

我的可能性是这样认为的!

  1. 在 RDLC 报告中,在运行时更改报告 XML。(非常复杂,因为大小和颜色是随机的)

  2. ,每周创建一个新报告,并在最后将它们显示为主报告中的子报告。(如果我必须创建 15 周或更长时间的报告,这是否有效)。

  3. 为每周创建交叉表并将它们对齐以类似于上面的报告。

有人会建议我以上述格式生成报告的最佳方法是什么吗?是我缺少的东西。

Let suppose the result of my SQL query is

Colour   size    week 1  week2  week 3


Black      x       1      2       3

white      xx      1      1       0

yellow     large   2      1       0

I want to generate a report from this query like that.

               week 1               week 2              week 3
    ----------------------------------------------------------------
           x   xx   large       x   xx   large        x   xx   large
   ----------------------       --------------        -------------                                            
    black  1     0    0         2    0    0           3    0     0 

    white  1     0    0         0    1    0           0    0     0

    yellow 2     0    0         0    2    0           0    0     0

The possibilities I have think so for!

  1. In RDLC report change the the report XML at run time.(Very complex as sizes and colors are random)

  2. In Crystal report create a new report for each week and in last show them as subreports in main report.(Is this efficient what will be if I have to create report for 15 weeks or more).

  3. Create cross tab for each week and align them to look like above report.

Will some body suggest me what is best way to generate report in above format. Is some thing I am missing.

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

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

发布评论

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

评论(1

假情假意假温柔 2024-11-23 19:43:34

这可以通过分组来完成,但这需要付出很大的努力。假设周列是静态的,您实际上需要按每个数据列(周、大小、颜色)进行分组,然后将标题放在组页脚中,并带有摘要或运行总计,将您的值带到您需要的位置。

第一部分故意含糊不清,因为详细描述这一点会很复杂,所以我打算提出一个不同的解决方案。相反,您可以使用交叉表,但由于您的 sql 目前已构建,我相信每周都需要一个单独的交叉表。

我建议,它基于一些假设,但我假设您有能力控制进入报告的 sql 查询。如果可以的话,我相信最好重新格式化 sql 查询并让交叉表完成所有工作,而不是自己分解几周。在我回答的第一部分中,我假设几周是静态的,但我猜测这不是最终的解决方案,在这种情况下,我认为如果您使用如下所示的数据输出,您应该能够创建一个交叉表,该交叉表将允许您将周数显示为列。

Color    size    week    amt

Black      x       1      1
Black      x       2      2
Black      x       3      3
white      xx      1      1    
white      xx      2      1
white      xx      3      0
yellow     large   1      2
yellow     large   2      1
yellow     large   3      0

这是未经测试的,所以不要开枪打我,但我相信使用这种布局,您只需要在交叉表的列部分中设置周数和大小列字段,在交叉表的行部分中设置颜色字段以及汇总字段部分中的金额。

一般来说,在我提出解决方案之前,我会尝试回答这里提出的问题,并且明白我在这种情况下没有这样做,但是如果您有能力修改报告所采用的 sql 查询,我相信这是一个更好的解决方案。如果您有任何问题,请告诉我。希望这有帮助。

This could be accomplished using grouping, but it would take a great deal of effort. Assuming that the weeks columns is static, you would essentially need to group by every data column (weeks, size, color) and then put your headers in the group footers with summaries or running totals carrying your values down to where you need them.

The first part was intentionally vague because describing this in exact detail would be complicated so I was going to instead propose a different solution. Instead you can use a cross tab, but as your sql is currently constructed I believe it would require a separate cross tab for each week.

I propose, and it's based on some assumption, but I'm assuming that you have the ability to control the sql query coming into the report. If you could I believe it would be better to reformat the sql query and let the cross tab do all of the work instead of breaking the weeks out yourself. In the first part of my answer I assumed that the weeks were static, but I am guessing that this is not the ultimate solution in which case I think that if you use a data ouput as below you should be able to create a crosstab that will allow you to display your weeks as columns.

Color    size    week    amt

Black      x       1      1
Black      x       2      2
Black      x       3      3
white      xx      1      1    
white      xx      2      1
white      xx      3      0
yellow     large   1      2
yellow     large   2      1
yellow     large   3      0

This is untested so don't shoot me, but I believe with this layout you simply need to make the weeks and size column the fields in the columns section of the cross tab, the color field in the rows section of the cross tab and the amount in the summarized fields section.

In general I try to answer the question asked on here before I propose a solution and understand that I didn't in this case, but if you have the ability to modify the sql query the report takes in, I believe this is a better solution. Let me know if you have any issues. Hope this helps.

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