title: How can I sum values per day and then plot them on calendar from start date to last date
body: <p>I have a table, part of which is given below. It contain multiple values (durations) per day. I need two things 1) addition of durations per day. 2) plotting them on calendar in such a way that startdate is first_date from the table and last_date is Last_update from the table. I want to mention 0 for which date there is no duration. I think it will something like below but need help.</p>
  
  <pre><code>;WITH AllDates AS(
  SELECT @Fromdate As TheDate
  UNION ALL
  SELECT TheDate + 1
  FROM   AllDates
  WHERE TheDate + 1 &lt;= @ToDate
  )SELECT UserId, 
     TheDate,
     COALESCE( 
       SUM(
          -- When the game starts and ends in the same date
          CASE WHEN DATEDIFF(DAY, GameStartTime, GameEndTime) = 0 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/9F3wl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9F3wl.png" alt="enter image description here"></a></p>
  
  <p><strong>Here is what I am looking for</strong> <br />
  <a href="https://i.stack.imgur.com/EGAAr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EGAAr.png" alt="enter image description here"></a></p>