Supplying a Total for a Sort Group

advertisement
Supplying a Total for a Sort Group
When you want to give the total number of “people” let’s say with a specific sort group, you can use
count to print the total. For instance, let’s create a report, which prints the ID number and Name of
Freshman sorted on Major. Then, let’s count how many people are in each major, and print that
count. We could write:
TABLE FILE RTFILE
PRINT RT120
BY RT010
IF RT020 GE '12'
IF RT14C EQ 'FR'
IF RT005 EQ '2000F'
ON TABLE HOLD AS FROSH
END
JOIN RT010 IN FROSH TO KEY IN AAFILE AS J1
TABLE FILE FROSH
COUNT AA003 AS ‘Total,in,Major’
BY RT120 AS ‘Major’
PRINT AA002 AA003 AS ‘Name’
BY RT120
END
The above focexec uses two verbs. A request, which uses two verbs, is called a multi-set request. When
you use more than one verb in a request, LIST or PRINT can only be used once, as the last verb. The BY
phrase must be repeated. An example of the resulting report:
MAJOR
TOTAL
IN
MAJOR
ACCT
27
111111111
222222222
333333333
444444444
111222333
333222111
…
…
…
DOE, JOHN
DOVE, MARY
STOUFFER, MARTY
BACALL, LAUREN
CRUISE, TOM
AFLECK, BENJAMIN
AMST
2
ARTH
1
444111222
414121212
555121233
DISNEY, WALTER
LUCAS, GEORGE
MOORE, MARY-TYLER
STUDENT
NUMBER
NAME
Download