A `User` has\_many `Posts`. I want to retrieve the latest Post for each day (using `created_at`), ignoring other posts that may have been written earlier. Another way to pose this question might to ask for a each top salary earning employee by department - same thing I think.

How do I write this query in Rails (4.0 preferably)? I think it has something to do with `group` and `maximum` but I can't seem to get it. Is there a way to do it without resorting to SQL?

To clarify, what I'd like returned is an array of post objects that are the last ones written on their respective date.

Thanks!