X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 1F6D4310D38 for ; Tue, 1 Jul 2003 20:03:43 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 16522-06 for ; Tue, 1 Jul 2003 17:03:32 -0300 (ADT) Received: from www.postgresql.com (www.postgresql.com [64.117.225.209]) by svr1.postgresql.org (Postfix) with ESMTP id 967D9310D6B for ; Tue, 1 Jul 2003 17:02:48 -0300 (ADT) Received: from sabre.velocet.net (sabre.velocet.net [216.138.209.205]) by www.postgresql.com (Postfix) with ESMTP id C54DCCF6D40 for ; Tue, 1 Jul 2003 13:30:32 -0300 (ADT) Received: from stark.dyndns.tv (H162.C233.tor.velocet.net [216.138.233.162]) by sabre.velocet.net (Postfix) with ESMTP id 0096F138057; Tue, 1 Jul 2003 12:29:16 -0400 (EDT) Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) id 19XO0K-00084L-00; Tue, 01 Jul 2003 12:29:16 -0400 To: Josh Berkus Cc: Stefan Bill , pgsql-sql@postgresql.org Subject: Re: LEAST and GREATEST functions? References: <20030630201057.14507.qmail@web13905.mail.yahoo.com> <200306302032.23113.josh@agliodbs.com> In-Reply-To: <200306302032.23113.josh@agliodbs.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 01 Jul 2003 12:29:16 -0400 Message-ID: <87d6gu2otf.fsf@stark.dyndns.tv> Lines: 31 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200307/18 X-Sequence-Number: 14132 Josh Berkus writes: > Stefan, > > > I know the LEAST and GREATEST functions are not part > > of standard SQL, but they sure were handy where I came > > from (Oracle-land). > > Um, what's wrong with MAX and MIN, exactly? MAX and MIN are single-parameter aggregate functions. LEAST and GREATEST are two-parameter (though in postgres they could be defined for 3 and more parameters) scalar functions. eg: SELECT max(a) FROM bar would return a single tuple with the maximum value of a from amongst every record. whereas: SELECT greatest(a,b) FROM bar would return one tuple for every record in the table with a single value representing the greater of bar.a and bar.b. You could define your own functions to do this but it would be tiresome to define one for every datatype. -- greg