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!

How do i sum text in a table?

Status
Not open for further replies.

druggist

Technical User
Oct 11, 2000
36
US
I want to count the repeating text in a table that i have. If the word repeats, i want to be able to know how many times it does. For example, my DB has a list of adverse reactions from drugs. I want to be able to count the total number of times that a certain drug caused any type of reaction. How do i do that???
 
The following SQL for a query will read your table and group the records by DrugName and ReactionType and provide a count of each ReactionType for this drug.

Select A.DrugName, A.ReactionType, Count(*) as CountOfReactions
FROM tblYourTable as A
Group By A.DrugName, A.ReactionType;

Good luck. Get back with me if you need more assistance.


Bob Scriver
 
thanks alot, actually, i am using ms access and do not know how to implement my own sql. i did figure out how to get my answer though. thanks again...

druggist
 
When someone gives you SQL code just create a NEW query in ACCESS. When the dialog box opens up to pick a table or query just click close. Click the button in the upper left and select the SQL option. Copy and paste the code into the window.

Now what I gave you is the SQL example. It needs to have you change the table name and the field names but it is an example of Grouping on a fields to give you a condensed row identifier and then counting the the total number of rows that have the same identifiers. In this case Group on Drug and Reaction and then give you a count of these.
Example: Drug: Penicillen Reaction: Shock Count: 124

This would tell you that there were 124 Shock reactions to the drug Penicillen.

If you want to try it this way just get back with me with the name of your table and the names of the fields and I can fix it up and you can try it in a query.

Bob Scriver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top