I removed the group by clause but I got an error in mySQL development
mode. This is the statement after modification
@users = User.paginate :joins => :properties ,:select =>
'users.*', :page => params[:page], :order => 'count(properties.id)
DESC',:conditions => ['users.id != 1','users.id=properties.user_id']

this the error message i got
 misuse of aggregate: count(): SELECT users.* FROM "users"   INNER
JOIN "properties" ON properties.user_id = users.id  WHERE (users.id !=
1)  ORDER BY count(properties.id) DESC LIMIT 10 OFFSET 0


On Aug 12, 9:16 am, Marnen Laibow-Koser <li...@ruby-forum.com> wrote:
> Dave Aronson wrote:
> > On Wed, Aug 11, 2010 at 22:40, Mohammed Alenazi <vb4...@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-Koserhttp://www.marnen.org
> mar...@marnen.org
>
> Sent from my iPhone
> --
> Posted viahttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to