I have the next tables:
I need to create/populate the third table as following:
I painted the cells to make easier to understand. If I need to spell what I need, would be as follows:
Between 2018-06-05 and 2018-06-19 the value is 50.
Between 2018-06-19 and 2018-06-21 the value is 150.
Between 2018-06-21 and 2018-06-25 the value is 180.
Between 2018-06-25 and 2018-07-05 the value is 200.
I need to create a function to do this but I can't do this, I spend all day thinking about this problem but unhappily I can't dev the script.
I tried use some WHILE but....not success.



