Thank you all for the replies -
On Wed, Mar 16, 2011 at 3:05 PM, Igor Neyman iney...@perceptron.com wrote:
Select id, sum(col1) from tab
Where id 10
Group by id
Having sum)col1) 30;
Spend some time reading basic SQL docs/books - it'll help you
tremendously.
I have already read many
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;
#
-Original Message-
From: Alexander Farber [mailto:alexander.far...@gmail.com]
Sent: Tuesday, March 15, 2011 5:45 PM
To: pgsql-general@postgresql.org
Subject: Re: A join of 2 tables with sum(column) 30
And same for a simple select-query from1 table (w/o join):
# select id
Hello,
I have a table holding number of games per week for each user:
# select id,completed,yw from pref_match limit 3;
id | completed | yw
+---+-
OK2650139676 | 10 | 2011-03
OK513367704098 | 20 | 2011-03
OK513367704098 |
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
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
And same for a simple select-query from1 table (w/o join):
# select id from pref_match where sum(completed) 30 group by id;
ERROR: aggregates not allowed in WHERE clause
LINE 1: select id from pref_match where sum(completed) 30 group by...
^
--
Sent
On Mar 16, 2011, at 3:12 AM, Alexander Farber wrote:
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
On Mar 16, 2011, at 3:15 AM, Alexander Farber wrote:
And same for a simple select-query from1 table (w/o join):
# select id from pref_match where sum(completed) 30 group by id;
ERROR: aggregates not allowed in WHERE clause
LINE 1: select id from pref_match where sum(completed) 30 group