Re: How do I get min and max from an array of floating point values

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: pw <p(dot)willis(at)telus(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How do I get min and max from an array of floating point values
Date: 2008-09-03 07:43:01
Message-ID: 162867790809030043s7147421t47328fd36f365a93@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello

2008/9/2 pw <p(dot)willis(at)telus(dot)net>:
> Hello,
>
> Is it possible to get the min and max from an array of
> floating point values?
>
> The following doesn't return the min of the array values
> it simply returns the complete array...(??)
>
> SELECT min(string_to_array('1,2,3,4,5,6,7',',')::float[]);
>
> Thanks
>
> Peter
>

you should function
create function minimum(anyarray)
returns anyelement as $$
select min($1[i]) from generate_series(array_lower($1,1),
array_upper($1,1)) g(i);
$$ language sql immutable strict;

reagards
Pavel Stehule

> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Broersma 2008-09-03 12:28:04 Re: order of rows in update
Previous Message Claus Guttesen 2008-09-03 07:20:29 Re: seemingly slow for-loop in plpgsql