我有两个表:总和查询收集
Fixture (id, homeId, awayId...)
FixtureStats(id,playerId, teamOwnerId, rating, goals)
我想表明的目标,为在该播放器属于每个球员和球队的目标都总和。
PlayerId TeamOwnerId Goals TeamGoals
1 2 0 9
2 2 1 9
3 2 3 9
4 2 5 9
5 3 0 12
....
下面还是SQL查询缺少teamgoals
SELECT TOP (100)
PERCENT fs.teamownerid,
fs.playerid,
Count(f.id) AS Apps,
Sum(fs.goal) AS Goals
FROM dbo.fixturestats AS fs
INNER JOIN dbo.fixture AS f ON fs.fixtureid = f.id
WHERE (fs.rating > 0)
GROUP BY fs.playerid, fs.teamownerid
是什么2之间的关系? fs.fixtureid列在哪里链接? – Ajay2707 2015-02-06 05:08:53
'TOP(100)PERCENT'是什么? – 2015-02-06 05:15:59