hi, i have a sql statement which has a subquery on itself. it gets all
the unique invitees of a given event from table invitation. i came up
with the sql but i don't know how to convert it into a named_scope
which i can reuse in other places. please help.

sql:

select * from invitations inv
join (select event_id, user_id, max(invite_time) as last_invite_time
from invitations group by event_id, user_id) as last_inv
on
inv.event_id = last_inv.event_id and
inv.user_id = last_inv.user_id and
inv.invite_time = last_inv.last_invite_time and
inv.event_id = @event_id

thanks
batterhead

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to