Reports / Report aggregate functions |
Counts a number of rows in a report according to a condition.
[GROUP] COUNT(*) [ WHERE condition ]
This aggregate report instruction returns the total number of records qualified by the optional WHERE condition.
The WHERE condition is evaluated after any OUTPUT TO REPORT execution. Even if it is typically used in AFTER GROUP OF blocks, the aggregate expression is not evaluated in that block: Changing values of the WHERE clause in the AFTER GROUP context will not have an immediate effect.
Using the GROUP keyword causes the aggregate instructions to include only data of the current group of records that have the same value for the variable that you specify in the AFTER GROUP OF control block.
AFTER GROUP OF number SKIP 1 LINE PRINT 4 SPACES, "Shipping charges for the order: ", ship_charge USING "$$$$.&&" PRINT 4 SPACES, "Count of small orders: ", GROUP COUNT(*) WHERE total_price < 200.00 USING "##,###" SKIP 1 LINE PRINT 5 SPACES, "Total amount for the order: ", ship_charge + GROUP SUM(total_price) USING "$$,$$$,$$$.&&"