| |

VerySource

 Forgot password?
 Register
Search
View: 1810|Reply: 2

Novice ask for a date query statement

[Copy link]

2

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-9-28 16:30:01
| Show all posts |Read mode
The column type is TIMESTAMP

I want to do a statistical query, with a monthly interval, that is, how many records are found in all records per month
For example, how many records are there every month from January 2015 to January 2016?
Please enlighten me, thank you.
Reply

Use magic Report

2

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-9-30 13:30:01
| Show all posts
Already done
By the way, share with you, I hope it will be helpful to novices, no need to read it

SELECT COUNT(*),YEAR(t),MONTH(t) FROM test GROUP BY YEAR(t),MONTH(t);
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-30 14:00:01
| Show all posts
select date_format(date,'%Y%M'),count(*)
from table
group by date_format(date,'%Y%M');
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list