title: SQL Server How to break apart each hour from a time range
body: <p>I am trying to calculate the amount of minutes per hour in a date range. </p>
  
  <p>I would like it to return the amount of minuets that are in each hour. If the start time is <code>12:38PM</code> and the end time is <code>1:18PM</code> it would input <code>22</code> in the <code>12PM</code> column, and <code>18</code> in the <code>1PM</code> column. I am hoping to find a way to have it create the <code>24 hour</code> columns needed.  </p>
  
  <p>And then create another 24 columns and take the <code>Units_Sold/Minutes</code> and multiply them by the <code>minutes</code> in each hour to get the average total units sold per hour.  </p>
  
  <p>This is what I made it look line in Excel</p>
  
  <p><img src="https://i.stack.imgur.com/179hR.png" alt="screenshot"></p>
  
  <pre><code>SELECT account_number,
         asset_number,
         units_sold,
         minutes,
         open_date,
         start_time,
         end_time
  FROM sales
  </code></pre>