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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Distinct Records 1

Status
Not open for further replies.

inuman

Programmer
Feb 23, 2006
20
RO
Hi there!

I have a database containing records like these:

ID Name Qty Price
1 Prod1 5 15
2 Prod2 10 10
3 Prod1 10 15
4 Prod1 5 10

I have to make a query to obtain the following result:

Name Qty Price
Prod1 15 15
Prod1 5 10
Prod2 10 10

(Cumulate the quantities of records with the same Name AND Price)

Thank you in advance!
 
Use the sum function [Σ] - you will find it on the toolbar.
 
SQL code:
SELECT Name, Sum(Qty) As Quantity, Price
FROM yourTable
GROUP BY Name, Price

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top