This is easy to do with the dense_rank()
function in the query used to fetch the results:
select name, hour, value,
dense_rank() over (order by name) as row_num
from t;
Note: this will not necessarily assign the values in the order you have given. But each group will get a different value. If you need them in the order given, then you will need to identify the order. SQL tables are inherently unordered, so a column is needed to specify the ordering.