我想從MS Access查詢棒球數據庫,但是我的SQL語句一直卡在缺少的運算符上。下面是我通過SQL查詢:在SQL查詢中缺少運算符
SELECT
Master.nameFirst, Master.nameLast,
Master.nameFirst + ' ' + Master.nameLast as FULLNAME,
(SUM(Batting.H) + SUM(Batting.BB) + SUM(Batting.HBP))/(SUM(Batting.AB) + SUM(Batting.BB) + SUM(Batting.HBP)) as OBP,
SUM(Batting.H)/(SUM(Batting.H) + SUM(Batting.BB) + SUM(Batting.HBP)) as HitP,
(SUM(Batting.2B) + SUM(Batting.3B) + SUM(Batting.HR))/SUM(Batting.H) as ExtraP,
SUM(Batting.HR)/(SUM(Batting.2B) + SUM(Batting.3B) + SUM(Batting.HR)) as HRP,
SUM(Batting.3B)/(SUM(Batting.2B) + SUM(Batting.3B)) as TriplePerc,
SUM(Batting.HBP)/(SUM(Batting.BB) + SUM(Batting.HBP)) as HBPP
FROM
Master
INNER JOIN
Batting ON Master.playerID = Batting.playerID
WHERE
(Batting.playerID IN (SELECT playerID
FROM Master
WHERE (nameFirst = 'Ryan' AND nameLast = 'Howard'))
丟失的操作錯誤似乎把重點放在這個單一的表達:
(SUM(Batting.2B) + SUM(Batting.3B) + SUM(Batting.HR))/SUM(Batting.H) as ExtraP
但老實說,我看不出有什麼不妥的地方。我錯過了什麼?
爲什麼不通過在條件解決之前刪除條件來簡化查詢?如果你仍然不解決問題,那就問一個問題。 –
真的是你的專欄名稱嗎?這應該是問題。你正在使用哪個DBMS? –
請添加 - (1)數據庫+版本的相關標籤(2)相關表格的DDL(想想支持您的容易程度) –