Dalam SQL:
select * from messages group by year(created_at), month(created_at);
Dalam Rel:
Message.all.group_by { |m| m.created_at.beginning_of_month }
Dalam SQL:
select * from messages group by year(created_at), month(created_at);
Dalam Rel:
Message.all.group_by { |m| m.created_at.beginning_of_month }