Hi I have a database full of records of players and theirs match Stats.
Example:
( number means goals scored in match )
What I'm, trying to do is, select top X players that scores most of goals in Season.
I'm trying something like this, but I think there must be another Select with select count (number) or something.
SELECT TOP 10 [playerID]
,[number]
,[league]
,[yearID]
,[YellowCard]
,[RedCard]
FROM [ms4033].[dbo].[Shooter]
where yearID=28 AND league=4
group by playerID
Thanks for your time :-)
You need to SUM
number field and order by it like this;
SELECT TOP 10
playerID,
SUM([number]) as goals,
[league],
[yearID],
SUM([YellowCard]) as YellowCards,
SUM([RedCard]) as RedCards,
FROM [ms4033].[dbo].[Shooter]
WHERE yearID=28 AND league=4
GROUP BY playerID, league, yearID
ORDER BY goals DESC
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments