X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id C6B0C9DCBCB for ; Sun, 4 Dec 2005 18:25:24 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 44010-02 for ; Sun, 4 Dec 2005 18:25:21 -0400 (AST) X-Greylist: delayed 00:06:38.554244 by SQLgrey- Received: from smtp.gvtc.com (smtp.gvtc.com [216.177.160.80]) by postgresql.org (Postfix) with SMTP id 7CCD59DCBAA for ; Sun, 4 Dec 2005 18:25:22 -0400 (AST) Received: (qmail 14634 invoked from network); 4 Dec 2005 22:18:42 -0000 Received: from 12-181-68-5.block3.gvtc.com (HELO ?192.168.0.101?) (12.181.68.5) by smtp.gvtc.com with SMTP; 4 Dec 2005 22:18:42 -0000 Message-ID: <43936B04.3010006@gvtc.com> Date: Sun, 04 Dec 2005 16:17:40 -0600 From: Jim Johannsen User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 CC: "Pgsql-sql@postgresql.org" Subject: Re: How to get a count() where column < ''? References: <1133730772.5560.8.camel@Panoramix> <20051204133233.O57404@megazone.bigpanda.com> <1133732596.5560.11.camel@Panoramix> In-Reply-To: <1133732596.5560.11.camel@Panoramix> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.189 required=5 tests=[MISSING_HEADERS=0.189] X-Spam-Score: 0.189 X-Spam-Level: X-Archive-Number: 200512/20 X-Sequence-Number: 23562 Joost Kraaijeveld wrote: >Hi Stephan, > >On Sun, 2005-12-04 at 13:33 -0800, Stephan Szabo wrote: > > >>>SELECT COUNT(customers.objectid) FROM prototype.customers, >>>prototype.addresses >>>WHERE >>>customers.contactaddress = addresses.objectid >>>AND >>>zipCode < '2716BN' >>>ORDER By zipCode, houseNumber >>> >>> > > > >>In a non-grouped query like the above, I don't think that the order by is >>meaningful. You only get one row back anyway without a group by, and >>there's no single zipCode or houseNumber to associate with the row. >> >> >> >What do you mean by a non-grouped query? The query below gives the same >error: > >SELECT zipcode, COUNT(*) FROM prototype.customers, prototype.addresses >WHERE >customers.contactaddress = addresses.objectid >AND >zipCode < '2716BN' > > > Try SELECT COUNT(*) FROM prototype.customers, prototype.addresses WHERE customers.contactaddress = addresses.objectid AND zipCode < '2716BN'