The keyword G. groups selected rows by a specified column for the purpose of performing operations on each group. G. accumulates the results by group, but it does not order the groups. (Use AO. or DO. to ensure the desired order.)
For example, you can group by department to determine each department's average salary with the following steps:
When you run this query:
Q.STAFF | DEPT | SALARY | |
--------+---------+--------+----------|
| G.P.AO. | _S | P.AVG._S |
|
QMF produces this report:
DEPT AVG(SALARY)
------ ---------------
10 20865.862500000
15 15482.332500000
20 16071.525000000
38 15457.110000000
42 14592.262500000
51 17218.160000000
66 17215.240000000
84 16536.750000000
Generally, G. produces one group for each set of identical values in a column. If there are null values in the column, they form a single group.