1. 程式人生 > >sql將日期按照年月分組並統計數量

sql將日期按照年月分組並統計數量

dia col from 計數 code lec 數量 sql mat

1 SELECT DATE_FORMAT(releaseDate,"%Y年%m月") AS dates,COUNT(*) FROM t_diary GROUP BY DATE_FORMAT(releaseDate,"%Y年%m月")
ORDER BY DATE_FORMAT(releaseDate,"%Y年%m月") DESC ;
DATE_FORMAT();按照格式對某個日期操作
ORDER BY 排序
DESC 降序

sql將日期按照年月分組並統計數量