Crystal reports Crystal Reports:构建复杂的记录选择

Crystal reports Crystal Reports:构建复杂的记录选择,crystal-reports,record,sql-view,formula-editor,Crystal Reports,Record,Sql View,Formula Editor,我负责开发一个库存快照报告,该报告分为两种类型:订单和库存。除此之外,报告上只应显示具有特定状态的项目 I have a parameter that is used to determine the specific date for the report. {?endDate} I have a field in a view that pulls the date the item was received. {rec_date} I have a formula field that p

我负责开发一个库存快照报告,该报告分为两种类型:订单和库存。除此之外,报告上只应显示具有特定状态的项目

I have a parameter that is used to determine the specific date for the report. {?endDate}
I have a field in a view that pulls the date the item was received. {rec_date}
I have a formula field that pulls the group (orders/stock) -- {@grouping}
I have a formula field that pulls the status -- {@state}
基本上,我在记录选择中需要的是:

( @grouping = "Orders" and rec_date < {?endDate} and @state in (0,2,5) )

OR

( @grouping = "Stock" and rec_date < {?endDate} and @state in (1,2,3,5,7) )
(@grouping=“Orders”和rec_date<{?endDate}和@state in(0,2,5))
或
(@grouping=“Stock”和rec_date<{endDate}以及@state in(1,2,3,5,7))

我一直试图写这篇文章的任何方式都是无效的。如果有任何帮助,我们将不胜感激。

您的公式也必须放在弯曲的括号内:

( {@grouping} = "Orders" and rec_date < {?endDate} and {@state} in [0,2,5] )

OR

( {@grouping} = "Stock" and rec_date < {?endDate} and {@state} in [1,2,3,5,7] )
({@grouping}=“Orders”和[0,2,5]中的rec_date<{?endDate}和{@state})
或
({@grouping}=“Stock”和[1,2,3,5,7]中的rec_date<{?endDate}和{@state})

如何无效?你得到了什么错误?你的语法几乎是正确的。数组值需要包含在记录选择公式的方括号([])中。谢谢@craig,我刚刚测试了一下,注意到了这一点。我从来不记得数组语法:PThank you,我找不到任何关于该语法的易于参考的文档。不过,我可以找到一百万个关于它的研讨会和产品。如果在记录选择公式中使用公式字段(例如,[0.2.5])的话,很可能在读取记录时应用过滤器(记录从数据库返回时被包括/排除)。如果可能,针对数据库字段(例如[0,2,5]中的
{table.state})或SQL表达式(例如[02,5]
中的
{%state})进行测试;这些子句将被发送到数据库进行处理。性能提升将是显著的。