select floor((date_part('epoch', order_time - '2016-09-05 00:00:00') / 3600)), count(*)
from od_a_week
group by floor((date_part('epoch', order_time - '2016-09-05 00:00:00') / 3600));
The ::int
conversion follows the principle of rounding.
If you want a different result such as rounding down, you can use the corresponding math function such as floor
.