Use YEAR(), MONTH(), DAY() to get the year, month and 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) 获取日
Use date_format(application_date, '%Y'), which can be customized Date format
SELECT date_format(application_date, "%Y") as year, count(1) FROM patent GROUP BY date_format(application_date, "%Y")
Recommended: "mysql tutorial"
The above is the detailed content of How does mysql perform year, month, and day group statistical query based on date?. For more information, please follow other related articles on the PHP Chinese website!