Select SUM of points group by Team Name
I have structured my database like this:
Username | Team | Points
I want to create an SQL query which will show me 5 sum of total points from all teams which will have most points.
Should I use the SUM and GROUP BY with LIMIT 5?
Yes you are correct.
You need to Group by Team and Sum the points of each Team and use it in Order by with descending order. Finally limit first five rows
Select Team ,sum(Points) as team_sum from yourtable Group by Team Order by team_sum desc Limit 5