X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 458529FA5BA for ; Sun, 4 Jun 2006 23:10:02 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 90638-09 for ; Sun, 4 Jun 2006 23:09:53 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from wolff.to (wolff.to [66.93.197.194]) by postgresql.org (Postfix) with SMTP id 396829F9316 for ; Sun, 4 Jun 2006 23:09:53 -0300 (ADT) Received: (qmail 6315 invoked by uid 500); 5 Jun 2006 02:12:39 -0000 Date: Sun, 4 Jun 2006 21:12:39 -0500 From: Bruno Wolff III To: Mauro Bertoli Cc: pgsql-sql@postgresql.org Subject: Re: Get max value from an comma separated string Message-ID: <20060605021239.GA6293@wolff.to> Mail-Followup-To: Bruno Wolff III , Mauro Bertoli , pgsql-sql@postgresql.org References: <20060529112238.61079.qmail@web27009.mail.ukl.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060529112238.61079.qmail@web27009.mail.ukl.yahoo.com> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/51 X-Sequence-Number: 25287 On Mon, May 29, 2006 at 13:22:38 +0200, Mauro Bertoli 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.