Solved

Add numbers in a field in MySQL

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

21 Experts available now in Live!

Get 1:1 Help Now