oracle:
SELECT TRUNC(hold_trx_time, 'HH') AS hour, AVG(qty_1) as avg_qty
FROM a
WHERE TO_CHAR(hold_trx_time, 'HH24:MI:SS') >= '08:00:00' OR TO_CHAR(hold_trx_time, 'HH24:MI:SS') <= '08:00:00'
GROUP BY TRUNC(hold_trx_time, 'HH');
mysql:
SELECT DATE_FORMAT(hold_trx_time, '%Y-%m-%d %H:00:00') AS hour, AVG(qty_1) as avg_qty
FROM a
WHERE TIME(hold_trx_time) >= '08:00:00' OR TIME(hold_trx_time) <= '08:00:00'
GROUP BY DATE_FORMAT(hold_trx_time, '%Y-%m-%d %H');