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 E4D7E9FA2C7 for ; Mon, 29 May 2006 08:22:58 -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 78014-08 for ; Mon, 29 May 2006 08:22:47 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web27009.mail.ukl.yahoo.com (web27009.mail.ukl.yahoo.com [217.146.177.9]) by postgresql.org (Postfix) with SMTP id 8F14D9FA16E for ; Mon, 29 May 2006 08:22:47 -0300 (ADT) Received: (qmail 61081 invoked by uid 60001); 29 May 2006 11:22:39 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.it; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type; b=1HnqJ5fmYwSeqiaj+LLh/HjdQhjkMaUdyOaWoUR5K/GVTf4tmWCSTGq428J2s/KU0m8upJG0dMkjPg79A006LkiBGFwsf9oZARGkNJ3Q3GmRkWa2c9psc3p8+7tJwNo+yK/NeCNS+gsoD+jpThCh9NSg3A2cxEAKcVts6zNzLvc= ; Message-ID: <20060529112238.61079.qmail@web27009.mail.ukl.yahoo.com> Received: from [84.247.192.193] by web27009.mail.ukl.yahoo.com via HTTP; Mon, 29 May 2006 13:22:38 CEST Date: Mon, 29 May 2006 13:22:38 +0200 (CEST) From: Mauro Bertoli Subject: Get max value from an comma separated string To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/42 X-Sequence-Number: 25278 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 Chiacchiera con i tuoi amici in tempo reale! http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com