troubleshooting Question

Summation SQL Statement

Avatar of Mohamed Abowarda
Mohamed AbowardaFlag for United States of America asked on
Microsoft SQL ServerPHPMySQL Server
8 Comments3 Solutions401 ViewsLast Modified:
If I have the following table:

scores_log
-------------------------------------------------------------
userid            matches         score
-------------------------------------------------------------
1                     10                   500
2                      3                    300
8                      1                    800
1                      2                    200
8                      5                    600
-------------------------------------------------------------
As you see this is log records and userid can be duplicated multiple times.

What SQL statement statement should I use If I want to get the total summation of matches and score for each user (summation should include duplicated userid)?

Here is what I am trying to get using SQL statement:
-------------------------------------------------------------
userid            matches         score
-------------------------------------------------------------
1                     12                   700
2                      3                    300
8                      6                    1400
-------------------------------------------------------------

As you can see the duplicated rows are summated.

I am using MySQL.
ASKER CERTIFIED SOLUTION
Cluskitt

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros