title: Teradata SQL Cumulative Sum over date from another table
body: <p>The case In brief; the customer subscribes to a monthly service, the renewal date would be any day within the month, not just the month beginning, and he could also renew early or late (before/after the due date) then he consumes a from his quota bundle on daily basis and perhaps he could consume all his bundle quota befroe renewal date. So I need to calculate the <code>Running Total</code> for <code>Consumption_Value</code> based on the service renewal date, not the calendar date
  I have two tables:</p>
  <ul>
  <li>the First one: <code>Consumption_T</code> that holds the info for a subscriber daily consumption on specific offer IDs, like the below sample</li>
  </ul>
  <pre><code>|Subs_ID|Consumption_Date|Offer_ID|Quota|Consumption_Value|
  |-------+----------------+--------+-----+-----------------|
  |12345  |22-01-2021      |123     |140  |1                |
  |12345  |23-01-2022      |123     |140  |3                |
  |12345  |24-01-2023      |123     |140  |5                |
  |12345  |25-01-2022      |123     |140  |3                |
  |12345  |26-01-2023      |123     |140  |6                |
  |12345  |27-01-2024      |123     |140  |4                |
  |…      |…               |…       |…    |…                |
  |12345  |15-02-2021      |123     |140  |10               |
  |12345  |22-02-2021      |123     |140  |4                |
  </code></pre>
  <ul>
  <li>The other table <code>Renewal_T</code> is for the renewal dates like the one below:</li>
  </ul>
  <pre><code>|Subs_ID|Renewal_Date|Offer_ID|
  |-------+------------+--------|
  |12345  |22-01-2021  |123     |
  |12345  |22-02-2021  |123     |
  |12345  |18-03-2022  |123     |
  |12345  |19-04-2022  |123     |
  |12345  |15-05-2023  |123     |
  |12345  |16-06-2023  |123     |
  </code></pre>
  <p>The desired output will be like the below</p>
  <pre><code>|Subs_ID|Consumption_Date|Offer_ID|Quota|Consumption_Value|Running Total|
  |-------+----------------+--------+-----+-----------------+-------------|
  |12345  |22-01-2021      |123     |140  |1                |1            |
  |12345  |23-01-2022      |123     |140  |3                |4            |
  |12345  |24-01-2023      |123     |140  |5                |9            |
  |12345  |25-01-2022      |123     |140  |3                |12           |
  |12345  |26-01-2023      |123     |140  |6                |18           |
  |12345  |27-01-2024      |123     |140  |4                |22           |
  |…      |…               |…       |…    |…                |…            |
  |12345  |15-02-2021      |123     |140  |10               |140          |
  |12345  |22-02-2021      |123     |140  |4                |4            |
  </code></pre>