开发者

finding duplicates in a table [duplicate]

This question already has answers here: Closed 11 years ago.

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜