How to split rows based on year range

I have a table, where the columns StartYear and EndYear contain the Year range. I want to split the rows based on the Year range. see the attached screensort input and output needed and let me know how to do this in Matillion.

Hi @arasu2

You can try using CTE:

WITH RECURSIVE CTE_NAME AS (

SELECT PartNo, StartYear, EndYear, StartYear AS YearRange

FROM TABLE_NAME

UNION ALL

SELECT PartNo, StartYear, EndYear, YearRange + 1

FROM CTE_NAME

WHERE YearRange < EndYear

)