named_scope :active_between, lambda { |start, fin| {:joins =>
[:contacts, :favourites], :conditions => ["?< contacts.created_at and
contacts.created_at<? or ?<favourites.created_at and
favourites.created_at<?",start, fin, start, fin],:select => "DISTINCT
users.*"}}

Ok so this is a pretty ugly long query, but unfortunately it's
necessary to use or statements in the query.

The problem I'm having is with the final piece of this code :select =>
"DISTINCT users.* because of the join it's returning the amount of
times any user on the site does something, whereas I just want to know
how many unique users are doing stuff within particular time frames.

Also tried :group_by => "users.*" and group => "users.*", I'm pretty
new to Rails and SQL, any help would be greatly appreciated :-)

--

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