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. Figure 1: A
table with a complexnum_t column
CREATE TABLE tab1
(col1 INTEGER,
col2 complexnum_t,
col3 INTEGER);
INSERT INTO tab1
VALUES (1, row(1.5, 3.7)::complexnum_t, 24);
INSERT INTO tab1
VALUES (2, row(6.9, 2.3)::complexnum_t, 13);
INSERT INTO tab1
VALUES (3, row(4.2, 9.4)::complexnum_t, 9);
INSERT INTO tab1
VALUES (4, row(7.0, 8.5)::complexnum_t, 5);
INSERT INTO tab1
VALUES (5, row(5.1, 6.2)::complexnum_t, 31);
INSERT INTO tab1
VALUES (6, row(3.9, 4.6)::complexnum_t, 19);
The following query uses the SUM aggregate function on
the complexnum_t column, col2: