I wrote a simple query, it aggregates transaction amount on each user ID for every 3 days,
select user_id, sum(tran_amt) as tot_amt from transaction_table
where tran_dt>=cast('2016-12-31' as date) - INTERVAL '2' DAY
and tran_dt<='2016-12-31'
I want to calculate 3-day aggregated transaction amount for the whole month, from 12/01 to 12/31. I know how to do it in SAS, just replace the date '2016-12-31' with a macro variable, for example &tera_dt., something like this
%do i=1 %to 31;
call symput('tera_dt', "'"||put(intnx('day','1Jan2017'd,-&i,'b'),yymmdd10.)||"'")
But how can I create this date macro variable in Teradata? Thank you!
Or put it in another way, how to create a list of variables in Teradata? I want to create a macro variable called tera_dt, this variable contains dates from '2016-10-01' to '2016-10-31' total 31 dates, then I will run my query against this macro variable tera_dt. Thanks!