Solved

Add numbers in a field in MySQL

Posted on 2007-03-26
2
1,326 Views
Last Modified: 2012-06-27
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.
0
Comment
Question by:jmingo
2 Comments
 
LVL 11

Accepted Solution

by:
elfe69 earned 50 total points
ID: 18795542
SELECT SUM(viewnum) from TABLE
0
 
LVL 3

Expert Comment

by:amodmulay
ID: 18798580
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question