С самостоятельным объединением и агрегацией:
select t.startdate, t.enddate,
sum(value) addupvalue
from (
select
t.date startdate,
case
when min(tt.date) = max(m.date) then max(m.date)
else date_sub(min(tt.date), interval 1 day)
end enddate
from table1 t inner join table1 tt
on tt.date > t.date
cross join (select max(date) date from table1) m
group by t.date
) t
inner join table2 t2
on t2.date between t.startdate and t.enddate
group by t.startdate, t.enddate
order by t.startdate desc
См. Демоверсию . Результаты:
| startdate | enddate | addupvalue |
| ---------- | ---------- | ---------- |
| 2020-04-01 | 2020-04-08 | 37 |
| 2020-03-25 | 2020-03-31 | 29 |