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

解决方案 »

  1.   

    select * from 表 group by..
    having count(KeyWord)>1
      

  2.   

    Create Table Test
    (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