重庆小潘seo博客

当前位置:首页 > 重庆网络营销 > 小潘杂谈 >

小潘杂谈

mysql怎么根据date做年,月,日分组统计查询

时间:2020-09-23 08:00:06 作者:重庆seo小潘 来源:
使用 YEAR(), MONTH(), DAY() 来获取年月日SELECT YEAR(application_date) as years, count(1) FROM patent GROUP BY YEAR(application_date) ORDER BY years-- YEAR(application_date)获取年份-- MONTH(application_date) 获取月份-- DAY(application_date)

mysql怎么根据date做年,月,日分组统计查询

使用 YEAR(), MONTH(), DAY() 来获取年月日SELECT YEAR(application_date) as years, count(1) FROM patent GROUP BY YEAR(application_date) ORDER BY years-- YEAR(application_date)获取年份-- MONTH(application_date) 获取月份-- DAY(application_date)获取日使用 date_format(application_date, '%Y'),可自定义日期格式SELECT date_format(application_date, "%Y") as year, count(1) FROM patent GROUP BY date_format(application_date, "%Y")mysql怎么根据date做年,月,日分组统计查询

推荐:《mysql教程》以上就是mysql怎么根据date做年,月,日分组统计查询的详细内容,更多请关注小潘博客其它相关文章!