create table T(ID int, code varchar(10), SpotName varchar(10), Name varchar(10))
insert T select 1, 'A', '张三', 'SAD'
union all select 2, 'A', '李四', 'RG'
union all select 3, 'B', '王五', 'YTJ'
union all select 4, 'A', '张三', 'IIO'
union all select 5, 'C', '孙二麻子', 'ILL'
union all select 6, 'D', '王五', '654'
select * from T as A
where (select count(*) from T where code=A.code and SpotName=A.SpotName)>1
--result
ID code SpotName Name
----------- ---------- ---------- ----------
1 A 张三 SAD
4 A 张三 IIO