create table sales (
product_id int,
period_start date,
period_end date,
average_daily_sales int
);

insert into sales values(1,'2019-01-25','2019-02-28',100),(2,'2018-12-01','2020-01-01',10),(3,'2019-12-01','2020-01-31',1);


select * from sales;
with recursive cte (date) as
(
    select cast('2018-12-01' as date)
    union all
    select DATE_ADD(date, INTERVAL 1 day) from cte
    where date <=cast('2020-01-31' as date)
)
select s.product_id, year(a.date) as year,sum(s.average_daily_sales) as sales
    from cte a
join sales s on a.date between s.period_start and s.period_end
    group by s.product_id, year(a.date)
    order by 1, 2;

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: