Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return a sum of values common to an attribute in sql?

I have some rows that looks like this:

name  value
------------
Name  1
Name  2.8
Name  8

I want my return to be one row:

name  value
------------
Name  11.8

How do I force this to be the case? 11.8 Being the sum of the values there.

like image 421
Derek Avatar asked Feb 26 '23 22:02

Derek


1 Answers

You can try this

SELECT Name, SUM(Value)
FROM MyTable
GROUP BY Name
like image 156
bobs Avatar answered Feb 28 '23 10:02

bobs