By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE elbat (member varchar(4),
start_year integer,
end_year integer);
INSERT INTO elbat
VALUES
('John', 2013, 2017);
1 rows affected
WITH cte
AS
(
SELECT t.member,
t.start_year year
FROM elbat t
UNION ALL
SELECT t.member,
c.year + 1
FROM cte c
INNER JOIN elbat t
ON t.member = c.member
WHERE c.year + 1 <= t.end_year
)
SELECT *
FROM cte;
member | year |
---|---|
John | 2013 |
John | 2014 |
John | 2015 |
John | 2016 |
John | 2017 |