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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Count Fields

Author  Topic 

tpayne
Starting Member

18 Posts

Posted - 2009-01-22 : 14:11:37
I have a table called PMAppraisals. PMAppraisalID is the key. Another field is PMUser. I want to return a list of all PMAppraisalIDs that have a count(PMUser) >1. Could you help?

thanks.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-01-22 : 14:51:20
If PMAppraisalID is the key (each row has unique value) then how could any PMAppraisalID have more than one PMUser?

Be One with the Optimizer
TG
Go to Top of Page

tpayne
Starting Member

18 Posts

Posted - 2009-01-22 : 15:07:37
There is more than one record.
PMAppraisalID = 200 PMUser = 282
PMAppraisalID = 201 PMUser = 282

sorry for the confusion.

thanks.

Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-01-22 : 15:30:10
quote:
I want to return a list of all PMAppraisalIDs that have a count(PMUser) >1

so you mean you want a list of [PMUser]s that have a count(PMAppraisalID) > 1, right?

Be One with the Optimizer
TG
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-01-22 : 15:33:19
[code]
select PMUser, count(*) [PMAppraisalID_Count]
from PMAppraisals
group by PMUser
having count(*) > 1
[/code]

Be One with the Optimizer
TG
Go to Top of Page

tpayne
Starting Member

18 Posts

Posted - 2009-01-22 : 15:43:18
That works great. Thanks. I guess I was thinking backwards.

Go to Top of Page
   

- Advertisement -