Write an aggregate function
An aggregate is a function that returns one value for a group of queried rows. The aggregate function performs one iteration for each of the queried rows.
SELECT SUM(total_price) FROM items
WHERE order_num = 1002;
For this invocation of the SUM aggregate, each value of the total_price column that is passed into SUM is one aggregate argument. The total sum of all total_price values, which SUM returns to the SELECT, is the aggregate result.
- Extensions of built-in aggregates
- User-defined aggregates
You can write C user-defined functions to implement these aggregate extensions. For an overview of how to create aggregate functions and how to write them in an SPL routine, see the chapter on this topic in the Informix® User-Defined Routines and Data Types Developer's Guide. The following sections provide information specific to the creation of aggregate functions as C user-defined functions.