We help IT Professionals succeed at work.
Get Started

How can I sum a column in my Mysql query based on other column?

ltpitt
ltpitt asked
on
497 Views
Last Modified: 2015-03-20
I have this query:

SELECT distinct(number), user_name, doc_total FROM `docs` inner join getuti on docs.user = getuti.user_number WHERE date = '2015-02-24'

Open in new window


and I get this result:

number      user_name      doc_total (this is the income amount)
70      SARAH      8.25
71      SARAH      2.7
72      SARAH      19.65
73      SARAH      13
74      SARAH      21.75
and so on...

How can I sum all the doc_total values dividing those for each user_name?

Correct server response should be a few rows containing (colum names are example):

waiter_name  waiter_total_per_day

If more is needed I can provide access to my learning mysql server:

http://davidenastri.it/phpmyadmin

user:
saurabh

passwd:
saurabh

Thanks for your kind help!
Comment
Watch Question
Senior Software Engineer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 18 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE