記事数デイリー推移
select genre, DATE_FORMAT(`published_at`, '%Y-%m-%d') as date, count(id) from news where published_at>="2017-09-01 00:00:00" and status=10 GROUP BY date, genre ORDER BY genre, date
記事数マンスリー推移
select genre, DATE_FORMAT(`published_at`, '%Y-%m') as month, count(id) from news where published_at>="2015-01-01 00:00:00" and status=10 GROUP BY month, genre ORDER BY genre, month desc
解説
[DATE_FORMAT]
format 文字列に従って、date 値を書式設定します。
次の指定子が format 文字列で使用されている場合があります。書式指定子文字の前には、「%」 文字を付ける必要があります。