Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables 如何在配置单元SQL中将查询结果用作变量_Variables_Hive_Hiveql - Fatal编程技术网

Variables 如何在配置单元SQL中将查询结果用作变量

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

我无法访问配置单元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 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; 

谢谢你的帮助