Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Counting Distinct Entries

Author  Topic 

jp2code
Posting Yak Master

175 Posts

Posted - 2008-10-16 : 11:46:09
I'd like to run this kind of search:
SELECT DISTINCT [Title], Count([Title])
FROM dbo.Employees
No, that does not run. What I am trying to show is a Count of entries next to each Distinct Title.

Could someone help me with this?


Avoid Sears Home Improvement

jp2code
Posting Yak Master

175 Posts

Posted - 2008-10-16 : 11:52:01
[code]SELECT Count(DISTINCT [Title])
FROM dbo.Employees[/code]...is *not* what I need to find.

I need the number of entries for each distinct title.

I hope this is clear.


Avoid Sears Home Improvement
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-10-16 : 12:11:48

Hi try this..

SELECT [Title], COUNT([Title])
FROM dbo.Employees
GROUP BY [Title]
Go to Top of Page

jp2code
Posting Yak Master

175 Posts

Posted - 2008-10-16 : 12:19:12
Never would have guessed that.

Thanks!


Avoid Sears Home Improvement
Go to Top of Page
   

- Advertisement -