Skip to content
Advertisement

How to Split Hours between Min(Date) and Max(Date) into 4 Hours Slab in MySQL Server

My Table :

Data in Tables looks like below :

Required Result like :

Advertisement

Answer

I do not know how well this performs but it does return what you want:

EDIT I have updated it to filter out intervals with no data in the table.




You should probably store the results in a temporary table instead of just printing them out.

Below updated Code works for me.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement