gpt4 book ai didi

sql - Crystal Reports 中 WHERE 子句的等效项

转载 作者:行者123 更新时间:2023-12-04 18:24:16 25 4
gpt4 key购买 nike

这个 Crystal 报表程序被丢在我的腿上,我对它是全新的。我理解这个概念,但我在这里碰壁了。

还有一个类似的问题:
Crystal Reports equivalent of 'WHERE'

但是它和答案是针对(似乎)“总计”该列,而我只想仅在其中一列时显示该行(在这种情况下,如果“CostType”等于0)。

我有两个要读取的数据表来创建此报告。它们通过通用列名 (ItemKey) 连接。不幸的是,在第二个表中,同一项目有多个记录。我只想要 CostType 为 0 的项目。

这在 SQL 中非常简单,即使对于像我这样的初学者也是如此,但我不知道如何有效地说:“仅在 CostType 为 0 时显示项目”与 Crystal Reports。

Item_Cost 表(示例):

ItemKey      Special         Cost         CostType
001 TRUE 55.00 0
002 FALSE 10.00 0
003 TRUE 20.00 1

项目表(示例):
ItemKey      Description     Mode  
001 Whatever EE
002 Random AB
003 Unimportant GE

出现了什么:
Item         Description     Mode  
Box Whatever EE
Square Random AB
Circle Unimportant GE

我想展示的内容:
Item         Description     Mode  
Box Whatever EE
Square Random AB

我希望这一切都有意义。基本上,如果这是一个 SQL 查询,我只会在最后说“WHERE CostType = 0”,我不会得到所有其他具有不同成本类型的项目。

我应该提一下,这完全由 Crystal Reports 处理。我没有使用 SQL 字符串并将其传递给其他东西。显示窗口的函数如下:
    Dim PartsDemandReport As CrystalDecisions.CrystalReports.Engine.ReportDocument = New crptIndentedBomXLBom
PartsDemandReport.SetDataSource(GLOBAL_VARIABLES.GlobalBomIndented)

Dim CrystalReportViewerForm As New frmCrystalReportViewer
CrystalReportViewerForm.CrystalReportViewer1.ReportSource = PartsDemandReport
CrystalReportViewerForm.Show()
PartsDemandReport = Nothing

如果有一种方法可以简单地强制 Crystal Reports 添加“WHERE CostType = 0”,那就太好了。提前致谢。

最佳答案

有几种方法可以做到这一点:

  • 如果您不需要 CostType not equal to 0在整个报告中,您可以直接提供select expert充当 where clause用于 Crystal 报告。

  • 示例:

    转至 Report ---> Selection Formula ---> Record这个打开的公式窗口在下面的行中添加
    CostType = 0

    这将确保仅从数据库中检索成本类型 = 0

    2.如需 cost type <> 0报告中的任何地方。然后为 Item 添加以下条件, DescriptionMode

    示例
    @Item:

    if cost type = 0
    then <<Database Item field >>

    将其放在项目列的详细部分。

    同样的方法也适用于其他列。

    关于sql - Crystal Reports 中 WHERE 子句的等效项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23142700/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com