Try OpenEdge Now
skip to main content
ABL Reference
ABL Syntax Reference : COUNT-OF function
 

COUNT-OF function

Returns an INTEGER value that is the total number of selected records in the file or files you are using across break groups.

Syntax

COUNT-OF ( break-group )
break-group
The name of a field or expression you named in the block header with the BREAK BY option.

Example

This procedure sorts all customers by state and then calculates the percentage of the total number of customers that are in each state. The COUNT-OF function provides the calculation with the number of customer records in the database.
r-cntof.p
FOR EACH Customer NO-LOCK BREAK BY Customer.State:
DISPLAY Customer.CustNum Customer.Name Customer.SalesRep Customer.State.
ACCUMULATE Customer.State (SUB-COUNT BY Customer.State).
IF LAST-OF( Customer.State) THEN
    DISPLAY 100 * (ACCUM SUB-COUNT BY Customer.State Customer.State) /
      COUNT-OF(Customer.State) FORMAT "99.9999%"
      COLUMN-LABEL "% of Total!Customers".
END.

See also

Aggregate phrase