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

Querying DB

Status
Not open for further replies.

TJunior

IS-IT--Management
Jan 18, 2002
33
DE
Is there a way that I can output a total occurance of a particular (or several) bit of I data.

Example, if I have the software name MS Access in a Software name field 10 times, How do I output:-

There are 10 copies of MS Access

Or similar

Can you shed some light please.
 
select SoftwareName, Count(SoftwareName)
from SoftwareTable
group by SoftwareName

this should work if the field with the software name is consistent.
 
What is the purpose of the 'Count(SoftwareName)' in the select line?
I thought it may have been a counter for the softewareName field but wasn't aware that this was possible (Is it?)
Just not sure about this part of it. Should have figured out the first part myself really. But thanks for your help, is very much appreciated.

Thanks again.

 
Using count will give you the number of copies. Used in conjunction with the group by it narrows it to a distinct listing.
ex...
SoftwareTitle
-------------
Excel
Excel
Word
Word
Word
Access
Access
Access

Running the query
select SoftwareName, Count(SoftwareName) as Copies
from SoftwareTable
group by SoftwareName

results:
SofwartName Copies
----------- -------
Word 2
Excel 3
Access 3

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top