【问题标题】:Summaries two column with 0 value on a specific column汇总特定列上具有 0 值的两列
【发布时间】:2012-09-18 12:16:14
【问题描述】:

我确定这是相当不寻常的情况,我似乎找不到解决方案。

我正在尝试报告 SQL DB 表;该表有一个名为 sample_bucket 的字段,它定义了用作样本的大小,在这个表中我们有 size01-size24 列。 此外,我们还有另一个名为“类型”的字段,我需要在类型 A 和 B 之间进行选择。

我在两个“公式字段”上使用以下代码根据 sample_bucket 的内容提取 sizeXX,如下所示:

公式1:

if {zzpom.Type}= "A" and {zzpom.SAMPLE_BK}=1 then {zzpom.SIZE01}
else
if {zzpom.Type}= "A" and {zzpom.SAMPLE_BK}=2 then {zzpom.SIZE02}
else
.
.
if {zzpom.Type}= "A" and {zzpom.SAMPLE_BK}=24 then {zzpom.SIZE24}
else 0

还有

公式2:

if {zzpom.Type}= "B" and {zzpom.SAMPLE_BK}=1 then {zzpom.SIZE01}
else
if {zzpom.Type}= "B" and {zzpom.SAMPLE_BK}=2 then {zzpom.SIZE02}
else
.
.
if {zzpom.Type}= "B" and {zzpom.SAMPLE_BK}=24 then {zzpom.SIZE24}
else 0

我过滤了{formula1}<>0 or {formula2}<>0,但是当我运行报告时,我得到了两列而不是一列:

公式1 公式2 |公式1 公式2
  6.5 0 | 0 12

我试图总结报告,但看起来 CR 在传播中运行这些公式!

我需要将这两列合并为:

公式1公式2
  6.5 12

任何帮助将不胜感激!

【问题讨论】:

    标签: sql crystal-reports report crystal-reports-2008


    【解决方案1】:

    如果这是在 CR 中,那么我猜这些公式位于单独的公式字段中。我会将公式合并到一个字段中。

    if ({zzpom.Type}= "A" or {zzpom.Type}= "B") and {zzpom.SAMPLE_BK}=1 then {zzpom.SIZE01}
    else if ({zzpom.Type}= "A" or {zzpom.Type}= "B") and {zzpom.SAMPLE_BK}=2 then {zzpom.SIZE02}
    

    【讨论】:

    • 感谢您的帮助,但我认为我不会工作,为了更清楚,我制作了一个数据库示例,如下所示:Sample_bk |类型 | … |尺寸_6 |尺寸_7 |尺寸_8 | 7 |一个 | … | .. | 6.5 | .. | 7 |乙| … | .. | 12 | .. |两者的条件相同,只是类型不同,同时我从相同的字段名称(例如 size_7)中获取数据,因为 sample_bk = 7。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-14
    • 2015-12-09
    • 2011-04-17
    • 1970-01-01
    • 1970-01-01
    • 2021-04-09
    • 2014-06-23
    相关资源
    最近更新 更多