Select * from tb a where exists(Select * from tb
Where KeyWord=a.KeyWord and Code=a.Code group by KeyWord,Code having count(1)>1)
order by code
Where KeyWord=a.KeyWord and Code=a.Code group by KeyWord,Code having count(1)>1)
order by code
having count(KeyWord)>1
(ID int identity primary key not null,
keyword varchar(10),
code char(2))insert test (keyword,code)
select '老师','AA'
union all select '学生','BB'
union all select '家长','CC'
union all select '老师','AA'
union all select '家长','CC'
GOselect * from test SELECT * FROM TEST T WHERE 1<(SELECT COUNT(*) FROM TEST WHERE
keyword=t.keyword and code =t.code)
order by keyword ,code,iddrop table test