MySQL query by year, month, week, day group 1. Query by year group SELECT DATE_FORMAT(t.bill_time,'%Y') month_time,sum(t.pay_price) total FROM f_bill t GROUP BY month_time; Query results 2. Query by month group SELECT DATE_FORMAT(t.bill_time,'%Y-%m') month_time,sum(t.pay_price) total FROM f_bill t GROUP BY month_time; Query results 3. Query by week group SELECT CONCAT(SUBSTR(DATE_FORMAT(t.bill_time,'%Y-%u') FROM 1 FOR 4),'第',SUBSTR(DATE_FORMAT(t.bill_time,'%Y-%u'),6),'周') week_time,sum(t.price) total FROM f_bill t GROUP BY week_time; Query results 4. Query by day group SELECT DATE_FORMAT(t.bill_time,'%Y-%m-%d') month_time,sum(t.pay_price) total FROM f_bill t GROUP BY month_time; Query results This is the end of this article about MySQL group query by time. For more relevant MySQL group query content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Discussion on horizontal and vertical centering of elements in HTML
>>: JavaScript function call classic example code
Table of contents What is the rest operator? How ...
In this article, we will use the libudev library ...
01. Command Overview The paste command will merge...
1. W3C versions of flex 2009 version Flag: displa...
echarts word cloud is an extension of echarts htt...
Table of contents 1. Resource files 2. Installati...
1. Command Introduction The seq (Sequence) comman...
A list is defined as a form of text or chart that...
Background In a list like the one below, clicking...
Often you will encounter a style of <a> tag...
All previous projects were deployed in the Window...
1. To build a PPTP VPN, you need to open port 172...
0. Background Hardware: Xiaomi Notebook Air 13/In...
In MySQL, how do you view the permissions a user ...
This article shares the specific code of js to ac...