Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sum and distinct query 1

Status
Not open for further replies.

ietprofessional

Programmer
Apr 1, 2004
267
US
Here is the table I'm working with and what I'd like to pull out of it. I hope you can help.

Initial Table:

Code:
product    units
product1     2
product1     1
product1     3
product2     4
product3     3
product3     5

What I'd like to pull:

Code:
product1     6
product2     4
product3     8

Thanks for all your help!

 
A simple aggregate query:
SELECT product, Sum(units) AS total
FROM yourTable
GROUP BY product;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi

Code:
Select Product, Sum(Units)
From MyTabel
Group By Product


Skip,

[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue]
 


Yea, I know! [soapbox] ;-)

Skip,

[glasses] [red]Be advised:[/red] Researchers have found another Descartes trueism, "Cogito ergo spud."
"I think; therefore, I YAM!
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top