我需要创建一个查询,显示至少有一个团队参加游戏时会议的平均出勤率。
我可以获得team1的平均值没问题。 Relationships screenshot
SELECT Conference.ConferenceName, AVG(Game.Attendance) AS AVG_ATT
FROM (Conference INNER JOIN School ON Conference.[ConferenceID] = School.[ConferenceID])
INNER JOIN Game ON School.[SchoolID] = Game.[Team1]
GROUP BY Conference.ConferenceName;
我遇到的问题是将Team2添加到等式中。
答案 0 :(得分:1)
您可以在Access SQL中使用比Table1.Field1 = Table2.Field2
更复杂的JOIN表达式,但请注意,您无法在查询设计器中编辑查询。
SELECT Conference.ConferenceName, AVG(Game.Attendance) AS AVG_ATT
FROM (Conference INNER JOIN School ON Conference.[ConferenceID] = School.[ConferenceID])
INNER JOIN Game ON (
School.[SchoolID] = Game.[Team1]
OR School.[SchoolID] = Game.[Team2]
)
GROUP BY Conference.ConferenceName;
答案 1 :(得分:0)
我改为团队表,这使查询非常容易。我喜欢Team1和team2在游戏桌内,我可能会尝试你的方法来看看它的运作情况。