how to sum timestamps by 5 minutes

I need help with taking sum of timestamps in sql by 5 mins or since I'm doing analysis so maybe i change it to 6, 7 or 10 mins , particularly in Exasol as it doesn't have all functions like datediff and dateadd.

sample data

the result should look like this :

Result data

will be helpful .


Solution 1:

Exasol has functions similar to datediff and dateadd: MINUTES_BETWEEN and ADD_MINUTES

My solution is based on this SO question:

select add_minutes (
        trunc (CONTACT_DATE, 'mi'),
        mod (extract (minute from CONTACT_DATE), 5)
    ) as START_TIME
    , count (*) as CNT
from visits
group by local.START_TIME

Here 5 is a constant which defines length of period in minutes.