Use sql to count the amount of data in every ten minutes
In mysql database, use SQL to calculate the amount of data within ten minutes.
Let's start with the table structure:
The desired result is: how many user_id are there every ten minutes?
Option 1:
Select from_unixtime (floor (UNIX_TIMESTAMP (start_time) / 600) * 600), COUNT (DISTINCT user_id) AS 'count' from user_live_hits_log_history
Group by FLOOR (UNIX_TIMESTAMP (start_time) / 600)
Scheme 2:SELECT RPAD (LEFT (start_time,15), 1914) AS start_time, COUNT (DISTINCT user_id) AS 'count' FROM user_live_hits_log_history GROUP BY LEFT (start_time,15)
As long as you are familiar with the application of these functions, you will find it very simple.