'Get a row for each year using SQL

I have this table:

product_id period_start period_end
1 2019-01-25 2019-02-28
2 2018-12-01 2020-01-01
3 2019-12-01 2020-01-31

I want:

product_id year
1 2019
2 2018
2 2019
2 2020
3 2019
3 2020

How can I get one row for each product_id and year combination in SQL?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source