I have two tables A and B , both tables are joined by UserID In table A i have a columns DOB, First-name and in table B i have column IP, now i need to count all the duplicate records. Also i need to list first-name of all those duplicate records I am Using sql server 2008
*The criteria to find duplicate record is ,it should have same DOB and IP
Please help me out, i couldn't come up with a proper query for this....
select first_name, DOB, IP
from
(select first_name, DOB, IP, count(*) over (partition by DOB, IP) as cnt
from a
join b on a.UserID = b.UserID) q
where cnt > 1