Previous Topic: Subgroup Aggregation With Multiple EntitiesNext Topic: Use Expressions as Aggregate Function Arguments


Subgroup Aggregation With Multiple Common Attributes

A subgroup can be based on more than one common attribute. Each common attribute used must appear in both the WITH THE SAME clause and the PLACING clause.

Multiple Common Attributes of the Same Entity

Use the following statement to find the number of classes by subject that start at a given time:

SUMMARIZE EACH GROUP OF class 
WITH THE SAME class_subject 
class_start_time 
PLACING class_subject INTO local class subject 
PLACING class_start_time INTO local class start time 
PLACING GROUP count(OCCURRENCES) 
INTO local ief_supplied count 
Multiple Common Attributes and Entities

Use the following statement to find the total salary of exempt and non-exempt employees by department:

SUMMARIZE EACH GROUP OF employee 
department 
WITH THE SAME department id 
employee classification 
PLACING department id INTO out department id 
PLACING employee classification INTO out employee classification 
PLACING GROUP sum(employee salary) INTO out employee salary 
WHERE DESIRED employee belongs_to DESIRED department 

Note: Department is not used by any aggregate function, but needs to be in the read list because it provides a common subgroup attribute.