Is it possible to group a range of values?

1

I made the following query:

'select t.net, t.hora, t.'data', t.'local' from domingos t
join(
select net, updated, count(*) from domingos
where 'data' = '07/05/2017'
group by updated, net
having count(*) > 4
) as u
on t.updated = u.updated
and t.net = u.net
group by t.net, t.hora, t.'data', t.'local'
order by hora;'

This query returns me the values in the figure below

Is there a parameter for group by that makes it possible to group the values of the column hora , considering, for example, that the values from 00:34:00 to 00:36:00 are represented by only one value? p>     

asked by anonymous 31.07.2017 / 19:46

1 answer

2

Try this:

SELECT t.net, u.hh, t.'data', t.'local'
FROM domingos t
JOIN (
    SELECT net, updated, HOUR(hora) AS hh, COUNT(*)
    FROM domingos
    WHERE 'data' = '07/05/2017'
    GROUP BY updated, net
    HAVING COUNT(*) > 4
) AS u
ON t.updated = u.updated
AND t.net = u.net
GROUP BY t.net, u.hh, t.'data', t.'local'
ORDER BY hora;

That is, instead of using t.hora in GROUP BY and SELECT , use u.hh which is HOUR(hora) .

    
31.07.2017 / 19:52