select s.id, t.*
from filelist as s
join (
select SensorId, FileName, count(*) as [count]
from filelist
group by SensorId, FileName
having count(*) > 1
) t on s.SensorId = t.SensorId and s.FileName = t.FileName
原文:http://www.cnblogs.com/chucklu/p/5980176.html