Jump to content
Sign in to follow this  
Bad_Student

Need Help finding duplicates in SQL

Recommended Posts

Looks like ID 1 is the ID that has the same a/b values.

How does ID 4 & 5 qualify?

 

Edited by niche

Share this post


Link to post
Share on other sites

Try either of them

select t1.Id,t1.a,t1.b from Table1 t1 inner join 
(select a,b,count(*) as num from Table1  group by a,b having count(*)>1) t2 on t1.A=t2.A and t1.B=t2.

 

select t1.Id,t1.a,t1.b from Table1 t1 inner join 
(select a,b,ROW_NUMBER() OVER (PARTITION BY a,b ORDER BY a,b) as num from Table1 group by a,b having count(*)>1) t2 on t1.A=t2.A and t1.B=t2.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...