title: How to sum() prices between date ranges?
body: <p>I'm trying to figure out how to make an operation in my table to get a sum of prices by periods; basically i have 4 tables: 'Rooms','Medias','Details' and 'Prices';
  Room is my main table with IDs, and i need to join child tables to get details, media and prices for each unit. That works fine as now:</p>
  <pre><code>@From as date
  @To as date
  
  SELECT  
  Unit.Id,
  Unit.Description,
  Details.Description,
  Medias.path,
  
  FROM Unit
  LEFT JOIN Details
      ON Unit.Id = Details.UnitId
  LEFT JOIN Medias
      ON Unit.Id = Medias.UnitId
  </code></pre>
  <p>I now need to add a third join to 'Price' table who has a structure like this:</p>
  <pre><code>   Id  UnitId      From         To        Price    
    -----------------------------------------------
      1   1855   2022-06-18  2022-07-08  203.8600        
      2   1855   2022-07-09  2022-08-12  128.5700    
      3   1855   2022-08-13  2022-08-19  102.8600  
      4   2600   2022-06-18  2022-07-08  231.8600        
      5   2600   2022-07-09  2022-08-12  322.5700    
      6   2600   2022-08-13  2022-08-19  122.8600   
  </code></pre>
  <p>What i'm trying to do is to add to my select a sum() of Prices over the period that comes to my stored procedure from the variables @From and @To, to get out a total price for a period passed.</p>
  <p>For example passing @From = '2022-07-07' and @To = '2022-07-11' it is supposed to give me:
  664.86 (203.8600 + 203.8600 + 128.5700 + 128.5700) for the unit 1855
  and
  1108.86 (231.8600 + 231.8600 + 322.5700 + 322.5700) for the unit 2600</p>
  <p>Hope i made this clear, thank you for helping!</p>