Skip to content
Advertisement

SQL Order by 2 conditions

Let’s say that I have a database, that looks like that:

I need to order by date and if days are the same after hour, so results should be:

I tried to write a simple query, but it couldn’t take into account 2 conditions, one after another:

Could anyone help with this issue ?

Thanks All !

Advertisement

Answer

The only real issue I can think of would be if hour were stored as a string. If so, use implicit conversion:

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