Link to home
Start Free TrialLog in
Avatar of jmingo
jmingo

asked on

Add numbers in a field in MySQL

Here's my sql statement so far

SELECT DISTINCT email, fromemail, viewnum from TABLE

I want an SQL statement that will add the numbers in the field viewnum.

Here's a sample output

email                     fromemail                 viewnum
john@here.com    bob@there.com      34
this@that.com       that@this.com        4

so basically i want the statement to give me 38.

Thanks, hope this was clear.
ASKER CERTIFIED SOLUTION
Avatar of elfe69
elfe69
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of amodmulay
amodmulay

SELECT SUM(viewnum) from your table,,,

but this will give u an outpot only for the sum...so if u want to display sum in front of all the columns then this wont work...
so u will have to write 2 different queries and then combine the results