Ruby on Rails Wednesday, December 4, 2013

I want to write a scope that returns the most recent (created_at) row  for each person_id    So this table    id   person_id   created_at  1    111            2013-12-01 08:00  2    222            2013-11-20 07:00  3    111            2013-12-10 09:00  4    333            2013-10-21 08:00  5    333            2013-10-15 08:00    should return this    2    222            2013-11-20 07:00  3    111            2013-12-10 09:00  4    333            2013-10-21 08:00    Can someone help me out?  Many thanks

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/814b8549-fa29-49a6-80bc-d3c870ce3a94%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment