Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 988662E00C0 for ; Mon, 7 Jan 2008 18:53:56 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 66004-01-5 for ; Mon, 7 Jan 2008 18:53:52 -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 307222E0037 for ; Mon, 7 Jan 2008 18:53:50 -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 m07MrQHf011604; Mon, 7 Jan 2008 17:53:27 -0500 Message-ID: <4782AD66.3060606@encs.concordia.ca> Date: Mon, 07 Jan 2008 17:53:26 -0500 From: Emi Lu Reply-To: emilu@encs.concordia.ca User-Agent: Thunderbird 2.0.0.6 (X11/20070728) MIME-Version: 1.0 To: Scott Marlowe CC: Josh Williams , pgsql-sql@postgresql.org Subject: Re: Get the max(value1, value2, value3) from a table References: <4782A1B2.5050804@encs.concordia.ca> <1199745537.5877.9.camel@godzilla.local.scalefeather.com> In-Reply-To: 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:53:27 EST X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/41 X-Sequence-Number: 29894 >>> select ?max?(col1, col2, col3) as result; >>> will return >>> >>> result >>> ------- >>> 5 >>> 8 >>> 12 >>> >>> (3 rows) >> 8.1 (I believe?) introduced GREATEST(), which does precisely what you're >> looking for. > > How would greatest give him three rows like that? Maybe I'm > misunderstanding what the OP was asking for... IF 8.1, "select greatest(col1, col2, col3) from test" is exactly what I am looking for. I would do the optional query by union/or for now. Thanks! Ly.