Disclosed is a method, system, and program for processing an aggregate
function. Rows that contain a reference to intermediate result structures
are grouped to form groups. For each group, aggregate element structures
are formed from the intermediate result structures and, if the aggregate
function specifies ordering, the aggregate element structures are sorted
based on a sort key.