Propongo esta solución (debería funcionar en la mayoría de motores de bases de datos):
Código SQL
[-]
with VentasxHora as (
select
sum(total) as venta,
EXTRACT(hour FROM fecha) as hora,
case
when Extract(hour from fecha) < '12:00' then 'Franja 1'
when Extract(hour from fecha) < '17:00' then 'Franja 2'
when Extract(hour from fecha) >= '18:00' then 'Franja 3'
else 'Franja XX'
end as Franja
from documentos
where (COBRADO)
and not borrado
and not invitado
and cast(fecha as date) =:fecha
group by hora
)
select
Franja,
Sum(ventas) as ventasxfranja
from ventasxhora
group by Franja