Re: A join of 2 tables with sum(column) > 30

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
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-16 07:35:46
Message-ID: D4D3A503-87D1-45EB-AF74-17D5CF3BF884@solfertje.student.utwente.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 15 Mar 2011, at 22:33, Alexander Farber wrote:

> I'm trying to change it to a sum, but get the error:
>
> # 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;

# 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%'
group by u.id, u.first_name
having sum(m.completed) > 30
order by sum desc limit 3;

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.

!DSPAM:737,4d80686f235882980188992!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2011-03-16 07:40:52 Re: Partitioned Database and Choosing Subtables
Previous Message tushar nehete 2011-03-16 05:25:23 how to use savepoint and rollback in function