Re: [GENERAL] Strict min and max aggregate functions

2016-11-20 Thread Tom Lane
Jeff Janes writes: > On Sun, Nov 20, 2016 at 2:45 AM, Pavel Stehule > wrote: >> you can use composite type instead array too. > I tried a composite type of (flag int, value anyelement) but you can't use > anyelement in a composite type. So the

Re: [GENERAL] Strict min and max aggregate functions

2016-11-20 Thread Pavel Stehule
2016-11-20 20:18 GMT+01:00 Jeff Janes : > On Sun, Nov 20, 2016 at 2:45 AM, Pavel Stehule > wrote: > >> >> >> 2016-11-19 22:12 GMT+01:00 Jeff Janes : >> >>> I need "strict" MIN and MAX aggregate functions, meaning they return

Re: [GENERAL] Strict min and max aggregate functions

2016-11-20 Thread Jeff Janes
On Sun, Nov 20, 2016 at 2:45 AM, Pavel Stehule wrote: > > > 2016-11-19 22:12 GMT+01:00 Jeff Janes : > >> I need "strict" MIN and MAX aggregate functions, meaning they return NULL >> upon any NULL input, and behave like the built-in aggregates if

Re: [GENERAL] Strict min and max aggregate functions

2016-11-20 Thread Thomas Kellerer
Jeff Janes schrieb am 19.11.2016 um 22:12: I need "strict" MIN and MAX aggregate functions, meaning they return NULL upon any NULL input, and behave like the built-in aggregates if none of the input values are NULL. This doesn't seem like an outlandish thing to want, and I'm surprised I can't

Re: [GENERAL] Strict min and max aggregate functions

2016-11-20 Thread Pavel Stehule
2016-11-19 22:12 GMT+01:00 Jeff Janes : > I need "strict" MIN and MAX aggregate functions, meaning they return NULL > upon any NULL input, and behave like the built-in aggregates if none of the > input values are NULL. > > This doesn't seem like an outlandish thing to want,

Re: [GENERAL] Strict min and max aggregate functions

2016-11-20 Thread Kim Rose Carlsen
> CREATE OR REPLACE FUNCTION strict_min_agg (anyarray,anyelement ) > RETURNS anyarray LANGUAGE sql IMMUTABLE AS $$ > SELECT CASE > WHEN $1 IS NULL THEN ARRAY[$2] > WHEN $1[1] IS NULL THEN $1 > WHEN $2 IS NULL THEN ARRAY[$2] -- use $2 not NULL to

[GENERAL] Strict min and max aggregate functions

2016-11-19 Thread Jeff Janes
I need "strict" MIN and MAX aggregate functions, meaning they return NULL upon any NULL input, and behave like the built-in aggregates if none of the input values are NULL. This doesn't seem like an outlandish thing to want, and I'm surprised I can't find other discussion of it. Perhaps because