Reputation: 502
I am getting an, missing EOF at '-' near HAB, the query for the most part looks correct. just not sure how to implement minus in 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;
Upvotes: 0
Views: 278
Reputation: 20860
Alias names should be quoted with backtick character (``)
characters, when you include any additional character such as space or dash.
So use following:
SELECT
a.playerID AS ID,
a.yearID AS yearID,
(b.HAB - a.EG) AS `HAB-EG`
Upvotes: 1