i have a table like this
NAME VALUE
-----------------
bla 1
bla 2
bla 2
bla 3
bla 1
bla 4
bla 2
How can i do a sum of ONLY different values , and ignore the repeating values (is it possible?)?
Something like this :
SELECT SUM(??condition?? value) as total FROM table
And the sum should be 10.
Thank you!
This should work:
Source: http://forums.mysql.com/read.php?97,203188,203787#msg-203787
Source: http://dev.mysql.com/doc/refman/5.1/en/group-by-functions.html#function_sum
The second solution is better because it does not create temporary table. Therefore it is faster.