SELECT i_logon, i_partno, sum(i_qty) AS i_qty FROM requirements_table, inventory_table
WHERE requirements_table.l_partn
Main Topics
Browse All TopicsI have a query (in MySQL):
SELECT l_partno, l_qty, i_login, FROM requirements_table, inventory_table
WHERE requirements_table.l_partn
Now, it is possible that one member (i.e. for one value of the login field) may have multiple entries for the same part number.
e.g.
i_login i_partno i_qty
john a123 107
john a123 63
paul a123 105
bob b456 11
bob a123 13
paul b456 442
I need to get the total quantity of each part for each member.
i.e.
john a123 170 (sum of 107 and 63)
paul a123 105
bob b456 11
bob a123 13
paul b456 442
I believe this is possible with SUM(i_qty) and GROUP BY, but I'm having trouble getting it to produce the correct results.
How should I alter the query to do this?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: rockmansatticPosted on 2004-06-09 at 07:42:10ID: 11270347
You may not have to use GROUP BY, possibly just SUM(i_qty) where i_login = something. and then haev this repeat for each login.
It could fairly easily be done using applicaton logic, this may be a second option to your pure sql code answer. You can have it added up on the page.
Ill see if I can get some code, someone may have a better quicker way.
Rockman