Counting data by date group interval

Hi all!

I’m a bit unsure, so thought I’d ask here. I’ve got a list of player sessions and want to query the last 24 hours and get the session count per hour. I could group the data by the hour, but if any hour had no data it would be skipped - I’m unsure what I’d need to do.

Looking for some guidance, not sure if SingleStore or MySQL in general has a function for this.

Thank you lots!

2 Likes

One solution to this problem is doing timeseries interpolation via stored procedures. See an overview of this approach here: Analyzing Time Series Data · SingleStore Documentation

2 Likes

Another approach which is quite common is doing the interpolation on the client side. Since you need to iterate through the data anyways to render, interpolating during the process shouldn’t cause any perf issues - and you gain the advantage of returning less data from the server!

2 Likes

Thanks for the reply Carl! I actually like this approach, and didn’t even see it. That’s very true that it then requires less work on the client.

Would need to figure out how I could do this within the client side JavaScript

2 Likes