Re: A join of 2 tables with sum(column) > 30 - Mailing list pgsql-general

From Alexander Farber
Subject Re: A join of 2 tables with sum(column) > 30
Date
Msg-id AANLkTimWsyOebZbTvgTjGo=uNhRAk1u0_ajze5DFr7mh@mail.gmail.com
Whole thread Raw
In response to Re: A join of 2 tables with sum(column) > 30  (Vibhor Kumar <vibhor.kumar@enterprisedb.com>)
Responses Re: A join of 2 tables with sum(column) > 30  (Alexander Farber <alexander.farber@gmail.com>)
Re: A join of 2 tables with sum(column) > 30  (Vibhor Kumar <vibhor.kumar@enterprisedb.com>)
List pgsql-general
Unfortunately I get:

# select u.id, u.first_name, sum(m.completed) from pref_users u,
pref_match m where u.id=m.id and u.id like 'DE%' and sum(m.completed)
> 30 group by u.id, u.first_name order by sum desc limit 3;
ERROR:  aggregates not allowed in WHERE clause
LINE 1: ...f_match m where u.id=m.id and u.id like 'DE%' and sum(m.comp...


On Tue, Mar 15, 2011 at 10:43 PM, Vibhor Kumar
<vibhor.kumar@enterprisedb.com> wrote:
>
> On Mar 16, 2011, at 3:03 AM, Alexander Farber wrote:
>
>> # select u.id, u.first_name, sum(m.completed)
>> from pref_users u, pref_match m
>> where u.id=m.id and u.id like 'DE%' and
>> sum > 30 group by u.id, u.first_name
>> order by sum desc limit 3;
>>
>> ERROR:  column "sum" does not exist
>> LINE 4: ...f_match m where u.id=m.id and u.id like 'DE%' and sum > 30 g...
>>
>> Any suggestions please? I've tried "... sum(m.completed) as total" too..
>
>
> Try following:
> select u.id, u.first_name, sum(m.completed) from pref_users u, pref_match m where u.id=m.id and u.id like 'DE%' and
sum(m.completed> 30 group by u.id, u.first_name order by sum desc limit 3; 
>

pgsql-general by date:

Previous
From: Vibhor Kumar
Date:
Subject: Re: A join of 2 tables with sum(column) > 30
Next
From: Alexander Farber
Date:
Subject: Re: A join of 2 tables with sum(column) > 30