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
1.1 Introduction to storage engines 1.1.1 File sy...
Table of contents 1. We must ensure that the vue/...
Dockerfile is a file used to build a docker image...
CSS3 achieves cool 3D rotation perspective 3D ani...
RULES can be used to control the style of the int...
The specific code is as follows: package epoint.m...
Table of contents 1. MySQL 8.0.18 installation 2....
Problem description: I used a desktop computer an...
Download and install MySQL 8.0.22 for your refere...
1. Download, install and activate CLion Just foll...
1. System installation package yum -y install mak...
This article shares the specific code of Vue to i...
Background In a list like the one below, clicking...
1. What is SQL injection? Sql injection is an att...
Preface For cost considerations, most webmasters ...