MySQL: How to group data per hour and get the latest hour

前端 未结 5 879
再見小時候
再見小時候 2020-12-31 16:15

I\'m trying to do a query that fetches data per hour but instead of the normal group by hour I want to narrow it down and only get the latest hour

5条回答
  •  Happy的楠姐
    2020-12-31 16:20

    I use this solution

    select date(PROCESS_DATE),hour(PROCESS_DATE),EVENT,COUNT(*) from statistics group by EVENT,date(PROCESS_DATE),time(PROCESS_TIME) order by 1 desc, 2 desc limit 1;
    

    Hope this assists someone.

提交回复
热议问题