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

From: "Yura Gal" <yuragal(at)gmail(dot)com>
To: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
Cc: pw <p(dot)willis(at)telus(dot)net>, 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 12:42:15
Message-ID: 3b6c69d80809030542n5f17cd77x13f61dc09d914750@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

If you use intarray type it is convenient to call buil-in intarray
functions for your purpose.

http://www.postgresql.org/docs/8.3/static/intarray.html

SELECT t.a[1] AS "min", t.a[array_upper(t.a, 1)] AS "max"
FROM (SELECT sort(string_to_array('2,3,4,15,6,7',',')::int[]) AS a)t;

--
Best regards, Yuri.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Christopher Maier 2008-09-03 13:38:35 Case-insensitive string prefix matching with parameterized query
Previous Message Richard Broersma 2008-09-03 12:28:04 Re: order of rows in update