Ruby on Rails Thursday, August 12, 2010

Dave Aronson wrote:
> On Wed, Aug 11, 2010 at 22:40, Mohammed Alenazi <vb4max@gmail.com>
> wrote:
>
>> properties.user_id = users.id �WHERE (users.id != 1) �GROUP BY
>> users.id,users.login,users.name ORDER BY count(properties.id) DESC
>> LIMIT 10 OFFSET 0):
>
> I haven't run into this sort of thing, but from my general
> SQL/database knowledge, I'd guess that the grouping is causing the
> problem.
>
> I assume users.id is unique. Is that correct? If so, then grouping
> on it (:group => 'users.id') is useless.

It doesn't matter if it's unique. There's no aggregate function in this
query, so there's no point to a GROUP BY clause. Remove it. MySQL may
just be ignoring it; Postgres is quite correctly telling you that it
makes no sense for it to be there.


-- 
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org

Sent from my iPhone
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment