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

Totaling Records based on Text Field

Status
Not open for further replies.

jercsr

Technical User
Sep 15, 2003
16
US
Hi,

I have a table with a list of parts. Each record has a description field. However, when I query to total the records, the records with the same description are not being sorted and totaled. How do I total all of the records with the same description?

Thanks in advance.

Jeremy
 
Can you rephrase your question?
Do you just want the count of the duplicates?
Do you want the total count of all records with a description?
Or something else?

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Greg,

I'm trying to get a total of all records with the same description.

Thanks,

Jeremy
 
To get those with two or more, try:
Code:
SELECT Count(t1.[COLOR=red]ID[/color]) as Cnt, t1.Description
FROM TABLE t1
GROUP BY t1.Description
HAVING (((Count(t1.[COLOR=red]ID[/color]))>1));
To get all of them, remove the HAVING clause

Replace ID with your key field (or any non null field).

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
SELECT [Description field], Count(*) AS Total
FROM [list of parts table]
GROUP BY [Description field]
ORDER BY [Description field];

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top