Skip to content

Query the distribution of request methods

Round the second-level time to minute-level time based on time - time % 60. Use the from_unixtime function to convert the value of the time field to a timestamp. Use the date_format function to convert the time to the hour:minute format. Use the group by clause to group the data based on the time of integer minutes and method. Use the count function to calculate the number of times that a method is used per minute. The results are displayed in a flow chart, in which the x-axis represents the date field, the y-axis represents the c field, and the aggregated column represents the method field.

SQL
* |
select
  date_format (from_unixtime(__time__ - __time__ % 60), '%H:%i') as date,
  count(*) as c,
  method
group by
  __time__ - __time__ % 60,
  method
order by
  __time__ - __time__ % 60

SQLSample query result:

样例图片