Aggregate functions for opaque data types

You can extend the built-in aggregate functions, such as SUM and AVG, to operate on your opaque data type. You can also create new aggregates. Create user-defined aggregates describes how to extend or create aggregates.