简体   繁体   中英

How to set variable query count result in visual foxpro 7

I am new in Visual FoxPro. I want to count rows by some id and print it in the report. Where I should place this query and how to set it to variable?

If you want it at the top of the report, before it has iterated through all the data, you need to pre-calculate it.

select mytable
sum myvalue for id="ABC" to gnTotal
report form myreport to printer preview

In this scenario gnTotal will be visible to the report and you can just use it in a report expression.

If you want it in the summary band or you want subtotals by group you would use a report variable of type 'sum'. The expression for the variable would then be:

iif(id="ABC", mytable.myvalue, 0)

In other words if for a particular record the value of id is "ABC" then add myvalue to the sum, otherwise add zero.

Then use the report variable in an expression at the bottom of the report.

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