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

Counting records issue 1

Status
Not open for further replies.

BrenoAguiar

IS-IT--Management
Feb 8, 2005
81
0
0
US
I have a table like this:

ID Name Bcode Ccode
1 John 211 212
1 John 211 301
2 mary 020 025
2 mary 020 056
2 mary 020 059
3 cathy 112 115

And I need to count the records to show how many times "John" (or ID=1) shows and the same for "mary" and "cathy". I'm not that familiar with the DistinctCount Function, if that is the solution.

Any Help?
 
Select count(*) from Tblname where Name = 'John'

or

Select count(*) from tblName where ID = 1



Randall Vollen
National City Bank Corp.
 
SELECT ID, Name, Count(*) As CountOfCodes
FROM yourTable
GROUP BY ID, Name

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks to Both of you guys! But since I have 8500 records, I can not specify the Name. But the first solution would work too with only certain names. But Thanks to Both !

Breno
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top