Table Sales
date id_product total sales
2018-10-01 1 40
2019-09-01 1 20
2019-11-01 1 5
2019-12-01 1 40
2020-01-01 1 10
2020-02-01 1 15
2020-03-01 1 20
2020-08-01 1 10
2021-01-01 1 5
2021-02-01 1 8
2021-04-01 1 12
Table Product
id name
1 Book
2 Pen
How to query in MySql to get the number (serial/sequential number) and the total cumulative sales with an interval of 3 years to get results like this?
number name date sum_sales cummulative_sales
1 Book 2018 40 40
2 Book 2019 65 105
3 Book 2020 55 160
4 Book 2021 25 145