1
我想加盟無論在ID和playerID和一年yearID(以下模式)這些select語句中減去一個領域。此外減去別名HAB - EG
SELECT playerID, yearID, (E/ G) AS EG FROM fielding
WHERE yearID > 2005 AND yearID < 2009 AND G > 20;
SELECT id, year, (hits/ab) AS HAB FROM batting
WHERE year > 2005 AND year < 2009 AND ab > 40;
JUST SCHEMA
CREATE EXTERNAL TABLE IF NOT EXISTS fielding
(playerID STRING ,yearID INT ,teamID STRING ,lgID STRING ,
POS STRING ,G INT ,GS INT , InnOuts INT , PO INT,A INT, E INT,
DP INT , PB INT , WP INT ,SB INT ,CS INT , ZR INT) ROW
FORMAT DELIMITED FIELDS TERMINATED BY ',' LOCATION '/home/hduser/hivetest/fielding';
JUST架構
CREATE EXTERNAL TABLE IF NOT EXISTS batting(id STRING, year INT, team STRING,
league STRING, games INT, ab INT, runs INT, hits INT, doubles INT, triples
INT, homeruns INT, rbi INT, sb INT, cs INT, walks INT, strikeouts INT, ibb
INT, hbp INT, sh INT, sf INT, gidp INT) ROW FORMAT DELIMITED FIELDS
TERMINATED BY ',' LOCATION '/home/hduser/hivetest/batting';
只需要添加回蜱別名' HAB-EG'它應該產生 – dedpo