Skip to content
Advertisement

SQL sort by each hour with different dates

I have a sql table like this

How to I sort by each hour to get this:

Your help is very much appreciated 😀

Advertisement

Answer

Here is a MySQL solution:

select DATE_FORMAT(min(time), ‘%h:00’),sum(occ_val) from tbl group by hour(time)

See https://www.db-fiddle.com/f/czudbp5zug6HxX4TFV26GT/0

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