Application of a scalar function across a varying number of records within
an RDBMS using the RDBMS's SQL capabilities. This is accomplished by
determining a last row in a group of rows, sorting the rows and passing
the sorted rows to a scalar function, where the scalar function accepts
each row and stores the accepted rows in a temporary file space. When the
last row is encountered, the aggregate value is calculated using all of
the rows in the group, and then a filter is applied on the rows so that
only a row with the aggregate value is returned.