Crystal Reports中的WHERE子句的等效项

Kei*_*ith 4 sql where crystal-reports

这个Crystal Report程序被丢弃在我的腿上,我对它不熟悉.我理解这个概念,但我在这里碰到了一堵墙.

还有一个类似的问题: Crystal Reports相当于'WHERE'

但它和答案都指向(似乎)"总计"列,而我想只显示行中的一列(在这种情况下,如果"CostType"等于0).

我正在阅读两个数据表来创建此报告.它们通过公共列名称(ItemKey)加入.不幸的是,在第二个表中,存在同一项的多个记录.我只想要CostType为0的项目.

这是在SQL愚蠢的容易,即使是像我这样的初学者,但我无法弄清楚如何有效地说:使用Crystal Reports"如果COSTTYPE是0只显示一个项目".

Item_Cost表(示例):

ItemKey      Special         Cost         CostType
001          TRUE            55.00        0
002          FALSE           10.00        0
003          TRUE            20.00        1
Run Code Online (Sandbox Code Playgroud)

项目表(示例):

ItemKey      Description     Mode  
001          Whatever        EE 
002          Random          AB 
003          Unimportant     GE
Run Code Online (Sandbox Code Playgroud)

出现的内容:

Item         Description     Mode  
Box          Whatever        EE 
Square       Random          AB 
Circle       Unimportant     GE
Run Code Online (Sandbox Code Playgroud)

我要展示的内容:

Item         Description     Mode  
Box          Whatever        EE 
Square       Random          AB 
Run Code Online (Sandbox Code Playgroud)

我希望这一切都有道理.基本上,如果这是一个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
Run Code Online (Sandbox Code Playgroud)

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

Siv*_*iva 6

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

  1. 如果您不需要CostType not equal to 0整个报告,那么您可以直接给出水晶报告的select expert行为where clause.

例:

转到Report ---> Selection Formula ---> Record这个打开的公式窗口,添加下面的行

CostType = 0
Run Code Online (Sandbox Code Playgroud)

这将确保只从数据库中恢复成本类型= 0

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

@Item:

if cost type = 0 
then <<Database Item field >>
Run Code Online (Sandbox Code Playgroud)

将其放在Item列的详细部分中.

对于其他列也一样.