Re: Get max value from an comma separated string

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Mauro Bertoli <bertolima(at)yahoo(dot)it>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Get max value from an comma separated string
Date: 2006-06-05 02:12:39
Message-ID: 20060605021239.GA6293@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, May 29, 2006 at 13:22:38 +0200,
Mauro Bertoli <bertolima(at)yahoo(dot)it> wrote:
> Hi, I've a field that contain values-comma-separated
> like
> A) 1;2;3;;5 -- ;2;;4;5
> but also
> B) 12;34;18
> how I can get the max value?
> For A I tried:
> SELECT max(array_upper(string_to_array(answer,';'),1))
> FROM values;
> and work fine, but for B case I don't find a solution
> like
> SELECT max(string_to_array(answer,';')) FROM values;
>
> Any ideas?
> Thanks for any hint

Don't store the data like that in the database if possible.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Sullivan 2006-06-05 11:10:07 Re: Using Query Result in WHERE Clause
Previous Message Tom Lane 2006-06-04 02:10:11 Re: datestyle on windows environment: how to set?