The extended aggregate
After you execute the CREATE FUNCTION statement in Registering
the overloaded plus() function , you
can use the SUM aggregate on complexnum_t columns. For example,
suppose you create the tab1 table as the following code fragment
shows.
The following query uses the SUM aggregate function on
the complexnum_t column, col2:
SELECT SUM(col2) FROM tab1;
With the rows that A
table with a complexnum_t column has
inserted, the preceding query yields a complexnum_t value of:
ROW(28.6, 34.7)
As a side effect of the new plus() function, you
can also add two complexnum_t columns in an SQL expression,
as follows:
SELECT complex_num1 + complex_num2 FROM complex_nums
WHERE id > 6;