Skip to content
Advertisement

how to filter database data in sql server by per hour

datates

if i have the data like the picture above, let’s say 1 day data per minute, and i want to filter it to be per hour, so i will have 24 data, because i take the data per hour. how to do that

i have tried some queries, like this one using group by, but the result is not like i want. didn’t work for grouping the datas.

Advertisement

Answer

You can use row_number(). For instance, if you want the first value per hour:

If you want to sum the values, use aggregation:

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