請教一個Hive sql 變數的問題, 請幫忙看一下
第一種,運行正常
set hivevar:curr_date ='2017-03-11';
select * from mytable where dt = ${curr_date};
第二種,運行正常,但是不理解為什么將Select陳述句賦予變數,在后續呼叫這個變數的時候要這樣寫。
set hivevar:curr_date = Select Max(dt) from tb_date;
select * from mytable where dt in (${curr_date});
第三種,下面兩種寫法都報錯了,想達到的目的是,從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});
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/259071.html
標籤:分布式計算/Hadoop
