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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.