N
N
nikaose2020-05-09 15:45:23
MySQL
nikaose, 2020-05-09 15:45:23

How can I sum up the points of people by teams?

There are two tables:

Team ID User IDs
one 15648984
one 345934851
2 894894564
2 43958346

User IDs User Points
15648984 12
345934851 34
894894564 eight
43958346 6


Is it possible to write a query that will sum up users' scores by teams and display the sum of the team?
Team ID Sum of points
one 46
2 fourteen

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry from SportGoroda.ru, 2020-05-09
@nikaose

It can be so.

SELECT id as 'ID Команды', SUM(User_points) as 'Сумма очков' FROM comandTabl
LEFT JOIN userTabl ON comandTabl.id_user = userTabl.id
GroupBy id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question