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 D38EF9FA15C for ; Mon, 15 May 2006 18:50:18 -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 83568-04 for ; Mon, 15 May 2006 18:50:09 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 96B4B9FA19B for ; Mon, 15 May 2006 18:50:09 -0300 (ADT) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Mon, 15 May 2006 21:50:08 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 15 May 2006 16:50:08 -0500 Subject: Re: Find min and max values across two columns? From: Scott Marlowe To: emilu@encs.concordia.ca Cc: Tom Lane , Amos Hayes , pgsql-sql@postgresql.org In-Reply-To: <4468F558.7070407@encs.concordia.ca> References: <9558.1143234035@sss.pgh.pa.us> <4468F558.7070407@encs.concordia.ca> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1147729808.9755.157.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Mon, 15 May 2006 16:50:08 -0500 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/110 X-Sequence-Number: 25141 On Mon, 2006-05-15 at 16:40, Emi Lu wrote: > Hello, > > I tried "select greatest(max(a), max(b)) from public.test", but I got > the following errors: > > ERROR: function greatest(integer, integer) does not exist > HINT: No function matches the given name and argument types. You may > need to add explicit type casts. > > May I know where I can read the docs about greatest & least please. > > I am using PostgreSQL 8.0.7. You need to define your problem better. Assuming these data: a b 12 24 24 12 13 18 25 10 which should I get for greatest(max(a), max(b)) should I get? Do you just want 25,24??? In that case you don't need greatest. Do you need the highest total between the two, or what?