I do not know what to call this question. Please forgive the title if it does not correspond to the question. I have data on production and unplanned maintenance activities ordered by Equipment and then Moment. See the table below (see the bottom of the question for the text version):

Data should be grouped according to the specified colors, and the Duration column is summed up. Below is the result. Basically, unscheduled maintenance hours should be summed up with production hours until a new unplanned maintenance appears (thus grouping).
- , RANK() , , 500 000 . -, 5 . : lead lag, , , SQL (SQL Server 2008)
:

.
:
https://drive.google.com/file/d/0B8xKLs3osIfcVGRCVGJMQnBYWXc/view?usp=sharing
StartDate = Moment
EndDate
+---------------------+-----------+-----------+-------------------------+
| Moment | Duration | Equipment | DowntimeType |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-14 08:34:03 | 2.734444 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-14 11:39:26 | 0.015833 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-14 11:41:23 | 0.4925 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-14 12:10:56 | 0.679444 | DT46 | Unscheduled Maintenance |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-14 12:51:42 | 0.628888 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-14 15:23:48 | 0.650833 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-14 16:05:19 | 3.341111 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-14 19:44:01 | 7.292777 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-15 03:18:15 | 5.954722 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-15 09:50:54 | 3.899722 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-15 19:33:11 | 1.760277 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-15 21:18:48 | 0.637222 | DT46 | Unscheduled Maintenance |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-15 21:57:02 | 3.109722 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-16 01:14:15 | 4.128611 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-16 18:33:01 | 0.004166 | DT46 | Unscheduled Maintenance |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-16 19:19:38 | 2.580833 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-17 01:23:56 | 0.111388 | DT46 | Unscheduled Maintenance |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-17 01:30:37 | 0.293333 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-17 01:48:13 | 0.99 | DT46 | Unscheduled Maintenance |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-17 03:26:10 | 3.805833 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2014-07-17 07:14:49 | 1.435833 | DT46 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2015-11-28 01:18:43 | 1.283611 | DT63 | Unscheduled Maintenance |
+---------------------+-----------+-----------+-------------------------+
| 2015-11-28 02:47:50 | 0.224166 | DT63 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2015-11-28 03:17:09 | 7.085277 | DT63 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2015-11-28 11:12:14 | 2.519722 | DT63 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2015-11-28 18:36:54 | 3.239166 | DT63 | Unscheduled Maintenance |
+---------------------+-----------+-----------+-------------------------+
| 2015-11-29 03:20:04 | 1.735833 | DT63 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2015-11-29 05:07:52 | 8.631944 | DT63 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2015-11-29 23:53:44 | 6.074444 | DT63 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2015-11-30 23:04:51 | 14.720555 | DT63 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2015-12-02 01:06:50 | 0.001111 | DT63 | Production |
+---------------------+-----------+-----------+-------------------------+
| 2015-12-02 01:07:28 | 4.540277 | DT63 | Production |
+---------------------+-----------+-----------+-------------------------+