Wednesday, March 7, 2012

how to count this ?

Hi,
This is my table structure ,

Name

John
John
Raj
John
Raj

From the above table i want to count the repeated name and my output should be

Name Count

John 3
Raj 2

since no of jone in my table is 3 and number of Raj is 2 .
how to write the query for this ?

try it like this:

SELECT [Name],COUNT(*)AS [Count]FROM yourTableGROUP BY [Name]

No comments:

Post a Comment