Teradata имеет собственный синтаксис для создания временных рядов:
SELECT mytab.*, pd
- extract the begin of the period and split it in YEAR/MONTH
,To_Char(Begin(pd), 'MONTH')
,Extract(YEAR From Begin(pd))
FROM mytab
EXPAND ON PERIOD(start_dt, Last_Day(end_dt)) AS pd -- must be LAST_DAY to include the end month
BY ANCHOR PERIOD Month_Begin -- one row for each month