I’m using MySQL database, and I cannot really get your example to
work…
I have column called “created_at”
def archive @archive = Post.find(:all,
:select => “DATE_FORMAT(’%m %Y’) as month_year,
COUNT(posts.id) as count”,
:group => “month_year”,
:order => “month_year”)
end
and I’m getting error as follow:
Mysql::Error: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to
use near ‘) as month_year, COUNT(posts.id) as count FROM posts GROUP BY
month_year ORDER’ at line 1: SELECT DATE_FORMAT(’%m %Y’) as month_year,
COUNT(posts.id) as count FROM posts GROUP BY month_year ORDER BY
month_year