2017-01-08 35 views
0

我有一個具有參數日期值的BTEQ腳本。日期值是根據另一個選擇查詢設置的。我怎麼能執行選擇查詢閱讀的日期,並在BTEQ腳本中使用 例teradata betq從查詢分配變量

從表1從表1

使用閱讀MAX(order_date的)

選擇MAX(order_date的)作爲max_order_date 在max_order_date在BTEQ

選擇max_order_date爲report_run_dt .... 從表2 ...

如何讀取max_order_paramter並將其作爲日期參數存儲以傳遞給BTEQ

+1

如果你只需要在一個Select中只需要這個參數,你可以簡單地嵌入它:'select(從table1中選擇max(order_date))作爲report_run_dt,... from table2 ...' – dnoeth

回答

0

使用一列創建易失性表,插入變量。所以易變的表格將是一列,一行。現在用你的選擇查詢來使用它。

CREATE VOLATILE TABLE maxdt 
AS 
select max(order_date) as max_order_date from table1 
WITH DATA; 



select maxdt.max_order_date as report_run_dt, .... 
from table2 cross join maxdt;