AnsweredAssumed Answered

SQL - SUM working hours by month in current year

Question asked by igreguri Champion on Oct 1, 2017
Latest reply on Oct 4, 2017 by Kenji Hashimoto

I'd like count total working hours for pumps by month in current year.

This is a fairly complex problem, but maybe someone has an idea how to solve...


In my case, pump working time is in tags like:

LIKE (%.CUR_RUN_TIME)           working time from last start in hours

LIKE (%.RUN)                                pump status (1 – Start, 0 – Stop)


Need to count (pump tags) CUR_RUN_TIME all ultimate values in month when RUN tag value go from 1 to 0, because this last value is total from the last running period and next tame will start again fom 0.


Second problem is transitioning from month to next month if there is no break . In this case result must be divided by months. I hope I explained well.

Last column (if possible) in query result is current Total.


I found a quite similar example, but do not know how to do it here in my case.