一、GP或PGSQL
with recursive t(n) as (select date('2023-01-01') union all select n+1 from t where n < now())
select to_char(n, 'yyyy-mm') as ny from t group by ny order by ny
二、Hive
select add_months(FROM_UNIXTIME(unix_timestamp(SUBSTR(start_date, 1, 7), 'yyyy-MM')), pos) from
(SELECT add_months('2023-03-01', -11) start_date ) tmp
lateral VIEW posexplode (split(space(11), '')) t AS pos, val