Netezza:如何保存选择结果

时间:2014-01-02 20:13:31

标签: sql netezza

假设我有表R1 =(A,B,C,D)和R2 =(X,Y)。

如何将以下结果保存到(临时)表

select * from R1, R2 where R1.A=R2.X       (1)

同样,如果我想将选择结果保存到变量,例如,

select avg(C) from from R1, R2 where R1.A=R2.X   (2)

此外,在更改某些字段的名称时,连接两个表的最佳优雅查询是什么,例如query(3)的最短等价物是什么?

 select A, B, C, D, X as E, Y as F from from R1, R2 where R1.A=R2.X   (3)

1 个答案:

答案 0 :(得分:2)

(1) Create Temp Table tbl1 as
select * from R1 inner join
R2 on R1.A=R2.X 
distribute on random

(2) Create Temp Table tbl2 as
select avg(c) as avg_c from R1 inner join
R2 on R1.A=R2.X 
distribute on random

(3)使用as是重命名结果列/字段的好方法