Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 954CF2E33D9 for ; Wed, 5 Dec 2007 10:36:12 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 93767-09 for ; Wed, 5 Dec 2007 10:35:50 -0400 (AST) Received: from mx2.nic.fr (mx2.nic.fr [192.134.4.11]) by postgresql.org (Postfix) with ESMTP id C5A882E3403 for ; Wed, 5 Dec 2007 10:36:07 -0400 (AST) Received: from mx2.nic.fr (localhost [127.0.0.1]) by mx2.nic.fr (Postfix) with SMTP id 5A73D1C0187; Wed, 5 Dec 2007 15:36:05 +0100 (CET) Received: from relay2.nic.fr (relay2.nic.fr [192.134.4.163]) by mx2.nic.fr (Postfix) with ESMTP id 5563F1C0171; Wed, 5 Dec 2007 15:36:05 +0100 (CET) Received: from bortzmeyer.nic.fr (batilda.nic.fr [192.134.4.69]) by relay2.nic.fr (Postfix) with ESMTP id 4918A58ECBE; Wed, 5 Dec 2007 15:36:05 +0100 (CET) Date: Wed, 5 Dec 2007 15:36:05 +0100 From: Stephane Bortzmeyer To: Steve Grey Cc: pgsql-general@postgresql.org, Ashish Karalkar , "A. Kretschmer" Subject: Re: SQL Query Message-ID: <20071205143605.GA17215@nic.fr> References: <20071205103548.GD24799@a-kretschmer.de> <33481.2408.qm@web94314.mail.in2.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Debian GNU/Linux 4.0 X-Kernel: Linux 2.6.18-5-686 i686 Organization: NIC France X-URL: http://www.nic.fr/ User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/256 X-Sequence-Number: 125000 On Wed, Dec 05, 2007 at 11:43:08AM +0000, Steve Grey wrote a message of 153 lines which said: > First work out the maximum number of times each value of X will occur in the > table A better solution, when you do not know this maximum number, is CREATE AGGREGATE (http://www.postgresql.org/docs/8.1/interactive/xaggr.html) See details : http://www.bortzmeyer.org/agregats-postgresql.html (Yes, it is in french but the SQL examples are in english, variable names included, so they still can be useful for the OP).