| From: | Vibhor Kumar <vibhor(dot)kumar(at)enterprisedb(dot)com> |
|---|---|
| To: | Alexander Farber <alexander(dot)farber(at)gmail(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: A join of 2 tables with sum(column) > 30 |
| Date: | 2011-03-15 21:43:03 |
| Message-ID: | 23ABA336-9DA8-4DEF-BB4C-544B13DCD261@enterprisedb.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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;
Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
vibhor(dot)kumar(at)enterprisedb(dot)com
Blog:http://vibhork.blogspot.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alexander Farber | 2011-03-15 21:45:01 | Re: A join of 2 tables with sum(column) > 30 |
| Previous Message | Alexander Farber | 2011-03-15 21:42:31 | Re: A join of 2 tables with sum(column) > 30 |