Home > database > SQL queries a day, every hour of the amount of data statistical statements how to write
SQL queries a day, every hour of the amount of data statistical statements how to write
Time:10-21
Queries a day, every hour, history data message data volume table, how do you write statement
CodePudding user response:
1, write the subquery interleave the data of a day, and the number of hours for each record insertion time (the following code for the MySQL, HOUR for MySQL function, the number of hours that you used to retrieve the current time) 2 to 1 as the subquery according to grouping hours after let go, one day can be concluded that the amount of data statistics,
SELECT T.t, COUNT (1) the FROM (SELECT *, HOUR (createdate) t the FROM TABLE) t GROUP BY T.t