From: | "David Johnston" <polobo(at)yahoo(dot)com> |
---|---|
To: | "'Alexander Farber'" <alexander(dot)farber(at)gmail(dot)com>, "'pgsql-general'" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Trying to find miss and mister of the last month with highest rating |
Date: | 2011-07-07 22:32:12 |
Message-ID: | 01e001cc3cf5$b7952240$26bf66c0$@yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
-----Original Message-----
And why can't I add u.name, u.avatar
to fetch all the info I need in 1 pass?
# select r.id, count(r.id), u.name, u.avatar, u.city from pref_rep r,
pref_users u where r.nice=true and to_char(current_timestamp - interval '1
month', 'IYYY-MM') = to_char(r.last_rated, 'IYYY-MM') and u.female=true and
r.id=u.id group by r.id order by count desc limit 7;
ERROR: column "u.*" must appear in the GROUP BY clause or be used in an
aggregate function LINE 1: select r.id, count(r.id), u.name, u.avatar,
u.city
^
Is there a way to workaround it?
>>>>>>>>>>>>>>>>>>>>
I believe you need to put 'name' in quotes ( like u."name" )
The fact that the warning indicates "u.*" where you didn't use "u.*"
anywhere in your literal syntax means that PostgreSQL is interpreting
something funny. Trial and error should have narrowed down the options if
you didn't catch that "name" is so common as to likely be utilized by the
database.
Going from memory here...
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Dr. Tingrong Lu | 2011-07-08 00:39:29 | Re: Add Foreign Keys To Table |
Previous Message | Rich Shepard | 2011-07-07 21:12:41 | Re: Add Foreign Keys To Table |