Variables 如何在配置单元SQL中将查询结果用作变量
我无法访问配置单元sql中的shell包装器脚本,因此我需要帮助,以便仅在没有shell的配置单元sql脚本中修改下面的sql 下面两行SQL都不起作用,我想做的是从mytable中检索日期介于curr_date和Last_date之间的数据,如何修改它Variables 如何在配置单元SQL中将查询结果用作变量,variables,hive,hiveql,Variables,Hive,Hiveql,我无法访问配置单元sql中的shell包装器脚本,因此我需要帮助,以便仅在没有shell的配置单元sql脚本中修改下面的sql 下面两行SQL都不起作用,我想做的是从mytable中检索日期介于curr_date和Last_date之间的数据,如何修改它 set hivevar:curr_date = '2017-03-11'; set hivevar:Last_date = Select Max(dt) from tb_date; select * from mytable where d
set hivevar:curr_date = '2017-03-11';
set hivevar:Last_date = Select Max(dt) from tb_date;
select * from mytable where dt >= ${curr_date} and dt <= (${Last_date});
select * from mytable where dt between ${curr_date} and (${Last_date});
没有办法使用变量。使用子查询:
set hivevar:curr_date='2017-03-11';
select t1.*
from
mytable t1
cross join (Select Max(dt) as max_dt from tb_date) dt
where t1.dt >= ${curr_date}
and t1.dt <= dt.max_dt;
谢谢你的帮助