Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use date to make grouped Statistical query of year, month and Day in mysql

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

How does mysql use date to make year, month and day grouping statistical queries? In view of this problem, the editor summarizes this article today, hoping to help more students who want to solve this problem to find a more simple and easy way.

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) get year-MONTH (application_date) get month-DAY (application_date) get date

Use date_format (application_date,'% Y') to customize the date format

SELECT date_format (application_date, "% Y") as year, count (1) FROM patent GROUP BY date_format (application_date, "% Y")

The above is the specific operation of mysql using date to produce year, month and day grouping statistical query, the code is detailed and clear, if you encounter this problem in daily work, I hope you can solve the problem through this article. If you want to know more about it, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report