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

Finding totals

Status
Not open for further replies.
Joined
Apr 27, 1999
Messages
705
Location
US
Hello,

I have three columns in a table, Vendor, Model, Version. I need to find the total number of units for each Model and Version by Vendor.

So for instance, Vendor 1 has three Models A, B, C each with different versions on them.

Vendor 1
Model A - version 1.0 3 units
Model A - version 2.0 5 units
Model B - version 2.1 5 units
Model C - version 4.1 5 units

Vendor 2

Model X - version 5.0 3 units
Model Y - version 5.0 5 units
Model W - version 4.1 5 units
Model C - version 4.1 5 units

Any ideas?

Thanks for the help!
 
Code:
SELECT Model, Vendor, Version, SUM(Units) AS TotalUnits
FROM YourTable
GROUP BY Model, Vendor, Version
Is that what yuo want?


Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
bborissov,

Thanks for your help, but I am sorry if I did not explain this correctly. The Units field is not there. That is what I am trying to find out, the total for each of the models and version. Sorry again.

fengshui1998
 
Then you should count every record, Isn't it?

Code:
SELECT Model, Vendor, Version, COUNT(*) AS TotalUnits
FROM YourTable
GROUP BY Model, Vendor, Version

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top