我正在尝试加入在同一查询中过滤的表。我尝试了以下方法:
CREATE TABLE finaltable STORED AS ORC AS
SELECT a.col1, a.col2, a.col3, b.col4, b.col5, b.col6
FROM table1 a
LEFT JOIN (SELECT pid FROM table2 b WHERE dt = '2016-12' AND zip IN (94105, 925129, 90210, 90291, 90044, 10014, 10453)
ON a.pid = b.pid;
我收到了一个错误:
FAILED: ParseException line 5:0 cannot recognize input near 'ON' 'a' '.' in expression specification
我认为错误是由于一些别名问题引起的,所以我也尝试过:
CREATE TABLE finaltable STORED AS ORC AS
SELECT a.col1, a.col2, a.col3, c.col4, c.col5, c.col6
FROM table1 a
LEFT JOIN (SELECT pid FROM table2 b WHERE dt = '2016-12' AND zip IN (94105, 925129, 90210, 90291, 90044, 10014, 10453) c
ON a.pid = c.pid;
也失败了:
FAILED: ParseException line 4:123 missing ) at 'c' near '<EOF>'
任何有关如何解决上述问题的建议都将受到赞赏。
答案 0 :(得分:0)
您忘了关闭SELECT
声明。在c
)
LEFT JOIN (SELECT pid FROM table2 b
WHERE dt = '2016-12'
AND zip IN (94105, 925129, 90210, 90291, 90044, 10014, 10453)--->)<--- c