Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 73CF164FC24 for ; Wed, 24 Sep 2008 16:22:57 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 89072-03 for ; Wed, 24 Sep 2008 16:22:51 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.230]) by postgresql.org (Postfix) with ESMTP id 3B59364FC2F for ; Wed, 24 Sep 2008 16:22:50 -0300 (ADT) Received: by wr-out-0506.google.com with SMTP id c49so26548wra.19 for ; Wed, 24 Sep 2008 12:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=kBwHOIa2UBtgDKoRKO2ta8Xz5pIP8PKNsbb6QBWT2/A=; b=PMLDVLxdas4b/hWJddcIzjUcwgXFTKnh/cX0mWifzqxn4FyRm95/q/WU5fndkZ349O g7FuSRNFche1BjGXLGfzxZk67T1/Y/V/FR+GBRRy8MXqcqLEZF3I7dXQpx1uRckLbH/+ xoAo5NKQ4vSC6hrZTN9xvu/I3n7Um1gYEnbYw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=d8wlR+mkhIIdO87TUB2t36fY1WdX/H9cHTt1qWiERW9/PoZY9bq8HP8PCKjdfhIp8n 8J4PhjFfwO49U2XW3Pp2tBGpDUJ6FZjUK2pEWbBh6pS55WStXBeTonqhskBO86mbJBq6 Qec+XmyZiDB4QfUKFEeVTArpDkDya0vr6bNAA= Received: by 10.100.227.6 with SMTP id z6mr6299555ang.89.1222284169093; Wed, 24 Sep 2008 12:22:49 -0700 (PDT) Received: by 10.100.196.2 with HTTP; Wed, 24 Sep 2008 12:22:49 -0700 (PDT) Message-ID: <396486430809241222x65c13e33j80f8c0fc7c6e7039@mail.gmail.com> Date: Wed, 24 Sep 2008 12:22:49 -0700 From: "Richard Broersma" To: "Colin Copeland" Subject: Re: query planner and scanning methods Cc: pgsql-performance@postgresql.org, "team@caktusgroup.com s" In-Reply-To: <396486430809231557j25541f06q845e017553fc44d2@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <8559E6C3-47ED-40E4-99E6-C56B322310DA@caktusgroup.com> <396486430809231507t46edf20fxab469bedbd78e8cc@mail.gmail.com> <6D0802D6-371A-470C-AB1C-3CC20E543061@caktusgroup.com> <396486430809231557j25541f06q845e017553fc44d2@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/221 X-Sequence-Number: 31534 On Tue, Sep 23, 2008 at 3:57 PM, Richard Broersma wrote: > SELECT A."dimension_book"."call", SUM( B."dimension_book"."call" ) AS > OrderedRowNbr > FROM ( your_above_query_without_the_limits ) AS A > INNER JOIN ( your_above_query_without_the_limits ) AS B > ON A."dimension_book"."call" >= B."dimension_book"."call" > ORDER BY A."dimension_book"."call" > HAVING SUM( A."dimension_book"."call" ) % 10 = 0; Oops I just noticed that I used sum() where count() should be used and that I forgot to include the group by clause. Other than that, I hope the suggestion was at least halfway helpful. -- Regards, Richard Broersma Jr. Visit the Los Angeles PostgreSQL Users Group (LAPUG) http://pugs.postgresql.org/lapug