Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 173982E426D for ; Mon, 7 Jan 2008 18:39:19 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 31789-01 for ; Mon, 7 Jan 2008 18:39:14 -0400 (AST) Received: from perseverance.services.encs.concordia.ca (perseverance-96.encs.concordia.ca [132.205.96.94]) by postgresql.org (Postfix) with ESMTP id 5A9CC2E35AC for ; Mon, 7 Jan 2008 18:37:59 -0400 (AST) Received: from cacao.encs.concordia.ca (emilu@cacao.encs.concordia.ca [132.205.47.225]) by perseverance.services.encs.concordia.ca (envelope-from emilu@encs.concordia.ca) (8.13.7/8.13.7) with ESMTP id m07MbvgH008856; Mon, 7 Jan 2008 17:37:57 -0500 Message-ID: <4782A9C4.1030104@encs.concordia.ca> Date: Mon, 07 Jan 2008 17:37:56 -0500 From: Emi Lu Reply-To: emilu@encs.concordia.ca User-Agent: Thunderbird 2.0.0.6 (X11/20070728) MIME-Version: 1.0 To: Richard Broersma Jr CC: Scott Marlowe , pgsql-sql@postgresql.org Subject: Re: Get the max(value1, value2, value3) from a table References: <239138.99803.qm@web31804.mail.mud.yahoo.com> In-Reply-To: <239138.99803.qm@web31804.mail.mud.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.58 on perseverance.encs.concordia.ca at 2008/01/07 17:37:57 EST X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/37 X-Sequence-Number: 29890 > >> select max(col1) from table >> union all >> select max(col2) from table >> union all >> select max(col3) from table No, this is not what I prefer; it makes complicate query. > > Would the following work also? > > SELECT MAX( GREATEST( col1, col2, col3 ) ) > FROM TABLE; I would prefer this func. Unfortunately, the current version I have 8.02(http://www.postgresql.org/docs/8.0/static/functions-conditional.html) does not support this func I am afraid :( Thanks ! Ly.