Próbuję odtworzyć następujące kwerendy mysql w szynach 3Jak grupa na dzień i rok w Active Record w Rails3
select count(id), year(created_at), month(created_at) from table where published_state = 'published' group by year(created_at), month(created_at);
Próbowałem coś takiego:
results = Table.select('count(id), year(created_at), month(created_at)').where('published_state LIKE ?', 'published').group('year(created_at), month(created_at)')
ale nie zwraca tego, czego chcę.
ja po prostu to w zamian
[#<Table >, #<Table >, #<Table >, #<Table >, #<Table >, #<Table >,
#<Table >, #<Table >, #<Table >, #<Table >, #<Table >, #<Table >, #<Table >, #<Table >, #<Table >, #<Table >, #<Table >]
W jaki sposób można to osiągnąć?
Dzięki!
Tak, rzeczywiście, istnieje sposób na uwzględnienie identyfikatorów w każdym wyniku? – content01
Dzięki tej odpowiedzi bardzo mi pomogło ... – Sakeer