【问题标题】:teradata betq assigning variable from queryteradata betq 从查询中分配变量
【发布时间】:2017-05-22 15:17:10
【问题描述】:

我有一个具有参数化日期值的 BTEQ 脚本。日期值是根据另一个选择查询设置的。如何执行选择查询以读取日期并在 BTEQ 脚本中使用 示例

从 table1 中读取 max(order_date)

选择 max(order_date) 作为 max_order_date 从表1

使用 BTEQ 中的 max_order_date

选择 max_order_date 作为 report_run_dt, .... 从表 2 ...

如何读取 max_order_paramter 并将其存储为要传递给 BTEQ 的日期参数

【问题讨论】:

  • 如果您只需要在单个 Select 中使用该参数,您可以简单地将其嵌入:select (select max(order_date) from table1) as report_run_dt, .... from table2 ...

标签: sql unix teradata


【解决方案1】:

创建一列的可变表,插入变量。所以 volatile 表将是一列,一行。现在将它与您的选择查询一起使用。

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;

【讨论】:

    猜你喜欢
    • 2014-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多