checking for NULLS in aggregate

From: Seb <spluque(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: checking for NULLS in aggregate
Date: 2015-06-24 16:54:25
Message-ID: 87mvzp2gji.fsf@net82.ceos.umanitoba.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I've defined a function to calculate standard deviation of angular
values:

CREATE AGGREGATE public.stddev(angle_vectors) (
SFUNC=array_append,
STYPE=angle_vectors[],
FINALFUNC=angle_vectors_stddev_yamartino
);

The type angle_vectors is simply an array:

CREATE TYPE public.angle_vectors AS
(x double precision,
y double precision);
COMMENT ON TYPE public.angle_vectors
IS 'This type holds the x (sine) and y (cosine) components of angle(s).';

How can I protect this function so that NULL is returned whenever *all*
input rows are NULL?

Thanks for any feedback,

--
Seb

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gauthier, Dave 2015-06-24 17:20:37 Re: DB access speeds, App(linux)<->PG(linux) vs App(linux) <->MSSql(Windows)
Previous Message Merlin Moncure 2015-06-24 16:53:29 Re: native api or odbc?