Jump to content

Need Help finding duplicates in SQL


Bad_Student

Recommended Posts

  • 2 weeks later...

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

How does ID 4 & 5 qualify?

 

Edited by niche
Link to comment
Share on other sites

  • 1 month later...

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.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...