Is it possible to use e.g. in line like this
SELECT trunc(dateadd(month,mon,add_months(date_trunc('month', CURRENT_DATE), -9))) as dates
FROM months
instead of -9, I would like to have there maximum value of column created like this (so in this case 12):
with months as (
select 1 as mon union all select 2 union all select 3 union all select 4 union all
select 5 as mon union all select 6 union all select 7 union all select 8 union all
select 9 as mon union all select 10 union all select 11 union all select 12
Is it possible somehow in Redshift? I tried just like that
SELECT trunc(dateadd(month,mon,add_months(date_trunc('month', CURRENT_DATE), -MAX(mon))) as dates
FROM months
but it is not working as expected
monfield created? what if you create a column in the master table with the max value of themoncolumn and then use the resulting column in the function -- would that help?