I have one php page which must show "Total Score" of "COUNTRY" for example
Let's say we have the following...
Now what i want is to show total SCORE of SUA for example, which will be 30
SELECT score,country,COUNT(*) FROM users WHERE country GROUP BY score
You can use the sum function.
select sum(score) as 'total', country
from users
group by country
This will return something like:
+-------+---------+
| total | country |
+-------+---------+
| 30 | SUA |
| 7 | Canada |
+-------+---------+
And you can also filter out your query by country with the where clause:
select sum(score) as 'total', country
from users
where country = 'Canada'
Which would give the following:
+-------+---------+
| total | country |
+-------+---------+
| 7 | Canada |
+-------+---------+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With