我在HAB附近的' - '处得到一个缺少的EOF,大部分查询看起来都是正确的。只是不确定如何在HIVE中实施减去。
SELECT
a.playerID AS ID,
a.yearID AS yearID,
(b.HAB - a.EG) AS HAB-EG
FROM
(SELECT
playerID,
yearID,
(E/G) AS EG
FROM fielding
WHERE (
yearID > 2005
AND yearID < 2009
AND G > 20
)
) AS a
JOIN
(SELECT
id,
year,
(hits/ab) AS HAB
FROM batting
WHERE(
year > 2005
AND year < 2009
AND ab > 40
)
) AS b ON a.playerID = b.id AND a.yearID = b.year;
答案 0 :(得分:1)
当您包含任何其他字符(如空格或短划线)时,别名应使用backtick character (``)
个字符引用。
所以使用以下内容:
SELECT
a.playerID AS ID,
a.yearID AS yearID,
(b.HAB - a.EG) AS `HAB-EG`