shell—在配置单元的insert语句中使用多个select语句

jjhzyzn0  于 2021-07-14  发布在  Spark
关注(0)|答案(1)|浏览(470)

我是新来的。
我有三张这样的table:

  1. table1:
  2. id;value
  3. 1;val1
  4. 2;val2
  5. 3;val3
  6. table2
  7. num;desc;refVal
  8. 1;desc;0
  9. 2;descd;0
  10. 3;desc;0
  11. I want to create a new table3 that contains:
  12. num;desc;refVal
  13. 1;desc;3
  14. 2;descd;3
  15. 3;desc;3
  16. Wich num and desc are columns from table2 and refVal is the max value of column id in table1

有人能指导我解决这个问题吗。谢谢

vjhs03f7

vjhs03f71#

首先,您必须创建一个表来保存这个。

  1. CREATE TABLE my_new_table;

之后,您必须插入到这个表中,如下所示

  1. INSERT INTO TABLE my_new_table
  2. [PARTITION (partcol1=val1, partcol2=val2 ...)]
  3. select_statement1;

select_statement1 您可以使用通常用于联接和选择所需列的相同select。
更多信息,请点击这里

相关问题