Forum: Ruby on Rails MYSQL group by and order by query

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
589525f133e603e1f17af9b03176c000?d=identicon&s=25 Abhishek shukla (Guest)
on 2008-10-10 15:58
(Received via mailing list)
Hello friends,
i need to get the latest  record of same field
for e.g

there is a table called xyz and it contains the following field item_id,
created_at

so i want a single record for every similar item_id whose created_at is
the
latest.

i tried group by with order by but no success, Please help me with
proper
query.

Thanks
Abhi
23e4fc3add5443f51e55663cfc245d24?d=identicon&s=25 Erol Fornoles (Guest)
on 2008-10-10 16:43
(Received via mailing list)
On Oct 10, 9:57 pm, "Abhishek shukla" <bettera...@gmail.com> wrote:
> i tried group by with order by but no success, Please help me with proper
> query.
>
> Thanks
> Abhi

Xyz.maximum(:created_at, :group => :item_id)
This topic is locked and can not be replied to.