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
 Unique Records

Author  Topic 

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2011-03-16 : 10:49:55
Can anyone help? How do you count unique records in a table? I have a table that has multiple records for the same group identification number, I only want to count each group id one time....

Thanks in advance.....

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-03-16 : 11:03:18
SELECT COUNT(DISTINCT GROUPID)
FROM yourTable

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2011-03-16 : 11:28:59
Thanks, Jim. I had it backwards!

quote:
Originally posted by jimf

SELECT COUNT(DISTINCT GROUPID)
FROM yourTable

Jim

Everyday I learn something that somebody else already knew

Go to Top of Page

subhbwn
Starting Member

6 Posts

Posted - 2011-03-17 : 06:02:57
You may refer to this http://www.w3resource.com/sql/aggregate-functions/count-with-group-by.php
Go to Top of Page
   

- Advertisement -