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

counting entries 1

Status
Not open for further replies.

jtabb

Vendor
Jul 6, 2004
11
US
I have a query that contains a list of part number's. There are 4 different part numbers that repeat. How can I make a table or query that totals how many I have of each part number? (Should I be using DCount?)
 
Only use DCount if you don't care how long it takes !!!

Run this query ( Change table and field names as appropriate )


SELECT PartNumber, Count(PartNumber) As CountOfPartNumber
FROM tblPartsList
GROUP BY PartNumber




'ope-that-elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
(1) Taking your advice, I tried this:
SELECT [RTS P/N], Count (RTS P/N) As [Total]
FROM [RTS Schedule]
GROUP BY [RTS P/N]

and i got the following error message: Syntax Error (missing operator) in query expression 'Count (RTS P/N)'.

do you know why this would happen? thank's for responding so quickly!

(2) I also tried playing with it and wrote the following:
SELECT DISTINCT [RTS Schedule].[RTS P/N], DCount("[RTS P/N]","RTS Schedule") AS Total
FROM [RTS Schedule]
GROUP BY [RTS P/N]

Each part number was listed correctly in a column but the 2nd column (that should have been the totals for each part number) just gave the total number of records from the RTS Schedule table. Do you know what I did wrong?
 
Try either this:
SELECT [RTS P/N], Count([RTS P/N]) As [Total]
FROM [RTS Schedule]
GROUP BY [RTS P/N];
Or this:
SELECT [RTS P/N], Count(*) As [Total]
FROM [RTS Schedule]
GROUP BY [RTS P/N];



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

faq700-2190


to understand why you're having so much trouble with the field names that you're using.





G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top