title: Sum of other column's value on for continuous duplicate column's data in SQL
body: <p>I need to add duration value for only continuous column's data. Suppose Execute data coming 3 times in this table and each time it is coming 3 times, 2 times and 1 times. So I want to add duration column's data 3 times as per continuous of state column. 
  What I need here that execute will show only 1 time instead of continuous as 3 times and again same rule for 2nd execute which is showing 2 times so it will also display 1 time with cumulative sum of duration column's value. So each iterate rows will come with sum of duration value and show as single row</p>
  
  <pre><code>CREATE TABLE Tools
      ([ID] int, [StartDatetime] varchar, [EndDatetime] varchar, [duration] int,  [durationDatetime] varchar, [state] varchar(50), [stateCode] int)
  ;
  
  INSERT INTO Tools
      ([ID], [StartDatetime], [EndDatetime], [duration],  [durationDatetime], [state], [stateCode])
  VALUES
  
  (1367, '2018-03-15 10:02:52', '2018-03-15T10:19:32.7000000', 100, '1900-01-01T00:16:39.7800000', 'Execute', 6),
  (1367, '2018-03-15 10:02:52', '2018-03-15T10:19:32.7000000', 900, '1900-01-01T00:16:39.7800000', 'Execute', 6),
  (1367, '2018-03-15 10:02:52', '2018-03-15T10:19:32.7000000', 400, '1900-01-01T00:16:39.7800000', 'Execute', 6),
  (1367, '2018-03-15 10:02:52', '2018-03-15T10:19:32.7000000', 1000, '1900-01-01T00:16:39.7800000', 'other', 2),
  (1367, '2018-03-15 10:02:52', '2018-03-15T10:19:32.7000000', 50, '1900-01-01T00:16:39.7800000', 'Execute', 6),
  (1367, '2018-03-15 10:02:52', '2018-03-15T10:19:32.7000000', 52, '1900-01-01T00:16:39.7800000', 'Execute', 6),
  (1367, '2018-03-15 10:02:52', '2018-03-15T10:19:32.7000000', 8, '1900-01-01T00:16:39.7800000', 'other', 2),
  (1367, '2018-03-15 10:02:52', '2018-03-15T10:19:32.7000000', 4, '1900-01-01T00:16:39.7800000', 'other', 2),
  (1367, '2018-03-15 10:02:52', '2018-03-15T10:19:32.7000000', 740, '1900-01-01T00:16:39.7800000', 'Execute', 6)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/UoTNX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UoTNX.jpg" alt="enter image description here"></a></p>