Crystal 报告零值
嘿伙计们, 所以我有这份报告,我将其分为不同的年龄段。如果没有与年龄桶关联的行,我希望年龄桶的计数为零。所以我在数据库选择中做了一个外部连接,效果很好。但是,我需要根据数据库中的另一列添加一个组。
当我添加该组时,没有与之关联的行的年龄桶就会消失。我想这可能是因为我试图分组的列对于该行来说是空的,所以我在我的选择中添加了一个行号,然后按它分组(我基本上只需要按每一行分组,我可以不仅仅是详细说明...如果有必要,我可以对此进行更多解释)。但是添加行号后,没有数据的agebuckets仍然为空!当我删除我添加的这个组时,我会得到所有年龄段。
有什么想法吗?谢谢!!
Hey guys,
So I have this report that I am grouping into different age buckets. I want the count of an age bucket to be zero if there are no rows associated with this age bucket. So I did an outer join in my database select and that works fine. However, I need to add a group based on another column in my database.
When I add this group, the agebuckets that had no rows associated with them dissapear. I thought it might have been because the column that I was trying to group by was null for that row, so I added a row number to my select, and then grouped by that (I basically just need to group by each row and I can't just put it in the details... I can explain more about this if necessary). But after adding the row number the agebuckets that have no data are still null! When I remove this group that I added I get all age buckets.
Any ideas? Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为年龄组的外部连接并不也是其他任何年龄组的外部连接
组是 - 您只能保证每个数据集都有每个年龄组的一个,而不是每个[其他组]每个年龄组的一个。
因此,例如,如果您的另一个组是“区域”,则在外部连接到其余组之前,您需要从年龄范围表到区域表进行笛卡尔/交叉连接(以便获得年龄范围和区域的所有可能组合)你的数据集。
编辑 - 根据评论,如下所示的查询应该可以工作:(
假设它是需要分组到存储桶中的 event_date 。)
It's because the outer join to age group is not also an outer join to whatever your other
group is - you are only guaranteed to have one of each age group per data set, not one of each age group per [other group].
So if, for example, your other group is Region, you need a Cartesian / Cross join from your age range table to a Region table (so that you get every possible combination of age range and region), before outer joining to the rest of your dataset.
EDIT - based on the comments, a query like the following should work:
(assuming that it's the event_date that needs to be grouped into buckets.)
我无法理解你的问题。
我确实知道 Crystal Reports 的 NULL 支持在一些非常基本的方面缺乏。所以我通常尽量不依赖它。
解决这个问题的一种方法是在数据库查询中对年龄范围进行硬编码,例如:
这样您就一定能在想要零的地方得到零。
我意识到这不是对你的问题的直接回答。祝你好运。
I had trouble understanding your question.
I do know that Crystal Reports' NULL support is lacking in some pretty fundamental ways. So I usually try not to depend on it.
One way to approach this problem is to hard-code age ranges in the database query, e.g.:
This way you are sure to get zeros where you want zeros.
I realize that this is not a direct answer to your question. Best of luck.