finding duplicates in a table [duplicate]
Possible Duplicate:
SQL - How can I remove duplicate rows?
Hello all
How I can Write following query .
I have a table Trace and I want to get all lines there where ID colum开发者_开发问答ns and MC columns combinations are appear more then once.
for example all lines where ID = 2 and MC = 11 appear more then once .
Thanks
You could group on ID, MC, and use having to select combinations that occur more than once:
select ID
, MC
from Trace
group by
ID
, MC
having count(*) > 1
SELECT *
FROM Trace T1
INNER JOIN (
SELECT ID, MC
FROM Trace T2
GROUP BY ID, MC
HAVING COUNT(*) > 1
) T22
ON T22.ID = T1.ID
AND T22.MC = T1.MC
加载中,请稍侯......
精彩评论