(aggregates 4) PostgreSQL Object Relational DataBase Management System 集計関数の拡張(4) 合計と個数とを求める関数が必要な集計関数 sfunc1とsfunc2の両方を使う集計関数の登録 CREATE AGGREGATE my_average ( sfunc1 = int4pl, -- 合計 basetype = int4, stype1 = int4, sfunc2 = int4inc, -- カウント stype2 = int4, finalfunc = int4div, -- 割算 initcond1 = '0', initcond2 = '0'); 集計関数の使用例 SELECT my_average(salary) as emp_average FROM EMP; 集計関数の削除 DROP AGGREGATE my_average int4;