title: SQL Server total Duration of value
body: <p>I am working on a table containing the following (example below):</p>
  
  <pre><code>Device varchar(90)  Value varchar(1000)  Date_time datetime2(7)
  ---------------------------------------------------------------
  device1                  10              2017-30-11 13:55
  device1                  50              2017-30-11 14:00
  device1                 100              2017-30-11 14:45
  device1                  50              2017-30-11 14:55
  </code></pre>
  
  <p>Currently the date_time column is updated everytime the value column is updated.</p>
  
  <p>The above is just  an example - this table is much larger.</p>
  
  <p>What I am trying to achieve is to return a table for the last 7 days showing the total duration that device1 had a value of 10, a value of 50 and so on -
  I'm not sure if this is possible with the data I have.</p>
  
  <p>Edited: what I am trying to achieve is this:</p>
  
  <pre><code>Device           Value         Last_seven_days
  --------------------------------------------------
  device1            10          5 hours
  device1            50          5 hours 10 minutes
  device1           100          3 hours 5 minutes
  </code></pre>
  
  <p>How the time is displayed isn't that important - as long as it includes hours &amp; minutes</p>