Solved

Add numbers in a field in MySQL

Posted on 2007-03-26
2
1,328 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

763 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