Aggregated by year, statistics:
Select SUM (Mymoney) as Totalmoney, COUNT (*) as sheets from MyTable Group by Date_format (Col, '%Y ');
Summary by month, statistics:
Select SUM (Mymoney) as Totalmoney, COUNT (*) as sheets from MyTable Group by Date_format (Col, '%y-%m ');
Summary by quarter, statistics:
Select SUM (Mymoney) as Totalmoney,count (*) as sheets from MyTable Group by concat (Date_format (col, '%Y '), Floor (date_form At (Col, '%m ') +2)/3);
Select SUM (Mymoney) as Totalmoney,count (*) as sheets from MyTable Group by concat (Date_format (col, '%Y '), Floor (date_form At (Col, '%m ') +2)/3);
By hour:
Select SUM (Mymoney) as Totalmoney,count (*) as sheets from MyTable Group by Date_format (Col, '%y-%m-%d%H ');
Query this year's data:
SELECT * FROM MyTable WHERE year (From_unixtime (my_time)) = year (Curdate ())
Number of quarters with query data included:
SELECT ID, Quarter (from_unixtime (my_time)) from MyTable;
Query the data for this quarter:
SELECT * FROM MyTable WHERE quarter (From_unixtime (my_time)) = Quarter (Curdate ());
Monthly statistics:
SELECT * FROM MyTable where month (my_time1) = month (Curdate ()) and year (my_time2) = year (Curdate ())
This week's stats:
SELECT * FROM MyTable where month (my_time1) = month (Curdate ()) and week (my_time2) = Week (Curdate ())
MySQL statistics function record-monthly, quarterly, by day, time period