Select 在 Hive 中 Select
Select within Select in Hive
我正在尝试使用来自另一个 table t1 的值在输出 table t2 中插入记录。在这样做的同时,我还需要使用 t2 中 col3 列的最大值。
为了达到同样的效果,我尝试在 table t1 的 select 语句中使用 select max(c1)。
在 SQL 中同样适用。有没有其他方法可以在 Hive 中实现相同的目的?
INSERT INTO t2
SELECT t1.c AS col1,
(SELECT MAX(col3)+1 FROM t2) AS col2
FROM t1;
这是我遇到的错误
FAILED: ParseException line 7:1 cannot recognize input near '(' 'select' 'max' in expression specification
INSERT INTO t2
SELECT t1.c AS col1,
s.col2,
... you need to provide all columns here
FROM t1
cross join (select MAX(col3)+1 AS col2 FROM t2) s
;
我正在尝试使用来自另一个 table t1 的值在输出 table t2 中插入记录。在这样做的同时,我还需要使用 t2 中 col3 列的最大值。
为了达到同样的效果,我尝试在 table t1 的 select 语句中使用 select max(c1)。 在 SQL 中同样适用。有没有其他方法可以在 Hive 中实现相同的目的?
INSERT INTO t2
SELECT t1.c AS col1,
(SELECT MAX(col3)+1 FROM t2) AS col2
FROM t1;
这是我遇到的错误
FAILED: ParseException line 7:1 cannot recognize input near '(' 'select' 'max' in expression specification
INSERT INTO t2
SELECT t1.c AS col1,
s.col2,
... you need to provide all columns here
FROM t1
cross join (select MAX(col3)+1 AS col2 FROM t2) s
;