简体   繁体   English

将查询转换为 Crystal Report 公式

[英]Convert query to Crystal Report formula

I have this SQLl query我有这个 SQLl 查询

SELECT SUM(Area) * 10000
FROM TaxDecRecord
where RealPropertyUnitSubClassification like 'Residential'
and RealPropertyUnitClassification like 'TAXABLE PROPERTIES'); 

I tried this formula in Crystal Report but ended up with true or false我在 Crystal Report 中尝试过这个公式,但最终结果是 true 或 false

SUM({TaxDecRecord.Area}) * 10000 & 
{TaxDecRecord.RealPropertyUnitClassification}= "TAXABLE PROPERTIES" &
{TaxDecRecord.RealPropertyUnitSubClassification}= "Residential"

Your help is highly appreciated thank you!非常感谢您的帮助,谢谢!

Your formula is lacking logic for the conditional statements from your SQL query.您的公式缺少 SQL 查询中条件语句的逻辑。 Instead, they are simply statements being combined with a number.相反,它们只是与数字组合的语句。 These statements can only evaluate as True or False as written.这些陈述只能按照书面形式评估为 True 或 False。 You need to use IF..THEN..ELSE or a CASE statement to evaluate the conditional statements.您需要使用 IF..THEN..ELSE 或 CASE 语句来评估条件语句。 Try this formula:试试这个公式:

IF {TaxDecRecord.RealPropertyUnitClassification}= "TAXABLE PROPERTIES" AND TaxDecRecord.RealPropertyUnitSubClassification}= "Residential"
THEN SUM({TaxDecRecord.Area}) * 10000

Where this formula field is placed in the report will be important though.但是,此公式字段在报告中的位置很重要。 If it is used in a Header section, it may not sum the data correctly because there may be data rows that have not been evaluated when the header section prints.如果在 Header 部分中使用它,它可能无法正确地对数据求和,因为在打印 header 部分时可能存在尚未评估的数据行。 This would make the result of the formula an accumulating field that only sums the data rows that have already been evaluated.这将使公式的结果成为一个累加字段,该字段仅对已评估的数据行进行求和。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM