简体   繁体   中英

Convert query to Crystal Report formula

I have this SQLl query

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

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. Instead, they are simply statements being combined with a number. These statements can only evaluate as True or False as written. You need to use IF..THEN..ELSE or a CASE statement to evaluate the conditional statements. 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. This would make the result of the formula an accumulating field that only sums the data rows that have already been evaluated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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