## Teradata Scenario : Calculate Future Days

General
General covers Articles, Reference documentation, FAQs, Downloads and Blogs that do not belong to a specific subject area. General-purpose Articles about everything and anything
Highlighted
Enthusiast

## Teradata Scenario : Calculate Future Days

Hi Experts,&nbsp;
&nbsp;
We need your help to implement the following scenario.&nbsp;We have&nbsp;to calculate the number of future days for which&nbsp;demand could be satisfied by the stock on a particular day.
Here is the&nbsp;source data&nbsp;-

Date

Demand

Stock

7/2/2018

20

50

7/3/2018

30

100

7/4/2018

40

..

7/5/2018

50

&nbsp;..

7/6/2018

20

..&nbsp;
&nbsp;&nbsp;
The stock of 7/2 (50) is enough to satisfy full&nbsp;demand of 7/3 (30) and half demand of 7/4 (20/40=0.5) . (20&nbsp;remaining after 30 was consumed on 7/3)&nbsp; giving days: 1 + 0.5 = 1.5
&nbsp;
Similarly, the stock of 7/3 is enough to satisfy the full demand of 7/4 (40), full demand of 7/5 (50) and half demand of 7/6 [(100 - (50+40))/20=0.5]&nbsp;giving days = 1+1+0.5 = 2.5
&nbsp;
Target Data -

Date

Demand

Stock

Number of Days

7/2/2018

20

50

1.5

7/3/2018

30

100

2.5

7/4/2018

40

..

&nbsp;..

7/5/2018

50

..&nbsp;

&nbsp;..

7/6/2018

20

..&nbsp;
&nbsp;
&nbsp;
Your help would be greatly appritiated.
Thanks
&nbsp;
&nbsp;
&nbsp;