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?

Answers


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

Need Your Help

C++ While loop and Array

c++ arrays class for-loop iterator

I have made a application where you enter in all the marks and it gives you the average and also makes it repeat itself but the problem is that

Display Image on web page using Java

java jsp java-ee servlets

In my Java EE app, there is a function to upload images. when uploading a image, i'm saving image path in mysql database.