I have a table that stores user counts every 5 minutes for multiple devices. Each device has it’s own row per timestamp. As I show in my fiddle, I created a query to sum all of the rows per create_time for a particular day. I then added to the query to find the max sum. I then added to find the create_time of the group that has that max sum. I then combined them all together to get the individual rows that make up the group for the create_time that had the max sum. Great!
While it works for a specific day, I just can’t figure out how to do it for multiple days. I thought I could throw some group by date(create_time)’s in there but I clearly am not grasping group by with having. From this point, I can’t say I’ve tried anything else because I just can’t wrap my brain around it.
Any help would be much appreciated!
2
Answers
is this what you’re looking for? this code groups the users sums by date only
I don’t think that I completely understand your question. From what I understand you can run your query for each date in the database by using a procedure and cursors.