• Thanks on prompt replay(I was thinking that nobody will answer).

    I want to sum time of each state in minutes and group that times by the shifts), but time_stamps sometimes have difference in seconds, so I have to calculate in seconds and on the end transform in minutes.

    so each shift for selected date range(from date1 to date2) will have report with:

    total_alarm_time,

    total_running_time,

    total_stop_time,

    number of alarms(number machine_state=1),

    longest interval of machine running condition(machine_state=2),

    longest interval of machine alarm(machine state=1)

    To have better picture I did export table to access(file in attachment).

    I will wait your advice before I test your code which you did send me in last replay.

    Again many thanks on support.