user1345246
user1345246

Reputation: 145

How to find records in a group by where only 1 field is different

I have 4 fields (empno,jobcode,abscode,unittype) and want to find all the records when only the unittype is different

Upvotes: 1

Views: 65

Answers (2)

user4731576
user4731576

Reputation: 1

Almost had it:

Select empno,jobcode,abscode,Count(Distinct unittype) 
from Tab
Group by empno,jobcode,abscode
Having Count(Distinct unittype)>1

Upvotes: 0

bummi
bummi

Reputation: 27367

Select empno,jobcode,abscode,Count(unittype) 
from Tab
Group by empno,jobcode,abscode
Having Count(unittype)>1

Upvotes: 2

Related Questions