In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces mysql to achieve grouped queries by time method, the text is very detailed, has a certain reference value, interested friends must read!
mysql query method by time grouping: use the function [DATE_FORMAT (date,format)], date is the field name of the time type in the table, format time output format.
mysql query method by time grouping:
DATE_FORMAT (date,format): Function used to display date/time data in different formats.
Parameters:
date: The name of the field for the time type in the table.
format: Time output format.
format:
Statistics by year: SELECT DATE_FORMAT(date,'% Y') time,SUM(field name to be counted) FROM table name WHERE condition GROUP BY time
Statistics by month: SELECT DATE_FORMAT(date,'%Y-% m') time,SUM(field name to be counted) FROM table name WHERE condition GROUP BY time
Statistics by week: SELECT DATE_FORMAT(date,'%Y-%m-% d') time,SUM(field name to be counted) FROM table name WHERE condition GROUP BY time
Statistics by day: SELECT DATE_FORMAT(date,'%Y-% m') time,SUM(field name to be counted) FROM table name WHERE condition GROUP BY time
Statistics by week: SELECT DATE_FORMAT(date,'%Y-% u') time,SUM(field name to be counted) FROM table name WHERE condition GROUP BY time
Use:
SELECT DATE_FORMAT(come_time,'%Y') year,count(*) value FROM user where registration_time >'2017'GROUP BY year
Search Results:
The above is mysql to achieve by time grouping query method of all content, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.