Solved

Add numbers in a field in MySQL

Posted on 2007-03-26
2
1,320 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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now