我想用当前日期和减去90天前的动态参数化SQL查询,以获取最新数据。
select current_date();
返回2019-07-11
当前日期,但是:
SET start_date as select current_date();
返回未定义或'select current_date()'的字符串文字
我希望像这样设置查询:
%sql
SET training_window = 90
SET end_date as select date_format(current_date(), 'yyyy-M-d');
SET start_date = date_format(date_sub(start_date, training_window), 'yyyy-M-d');
select count(*)
from my_table
where submitted_dt BETWEEN ${start_date} AND ${end_date_date};