SQL: want to find duplicate records from a joined table result (The two tables are from two different DB's).?
-
Hi all, I want to find duplicate records from a joint table result (The two tables are from two different DB's). Bellow are the tables and my requirement. Table1 from DB D1 EmpID 205 205 205 206 207 207 208 209 210 211 Table2 from DB D2 PayID 205 206 207 208 209 210 211 i have joined these two tables on the basis of EmpID = PAYID and got the following result SELECT T1.EMPID,T2.PAYID FROM D1.table1 T1 INNERJOIN D2.table2 T2 on T1.EMPID collate Latin1_General_CI_AI =T2.PayID EmpID PayID 205 205 205 205 205 205 206 206 207 207 207 207 208 208 209 209 210 210 211 211 In this result 205 and 207 having duplicate, so i want a query to display the duplicate entries .
-
Answer:
Just add the following: GROUP BY T1.EMPID,T2.PAYID HAVING COUNT(*) > 1 This will summarize to just the distinct T1/T2 pairs and limit the resultset to only those groups that appeared more than once before summarizing.
TheMadPr... at Yahoo! Answers Visit the source
Other answers
SELECT T1.EMPID,T2.PAYID,count(t1.empid) Temp FROM D1.table1 T1 INNERJOIN D2.table2 T2 on T1.EMPID collate Latin1_General_CI_AI =T2.PayID group by t1.EmpID having count(t2.payid)>1
nagarjun
Related Q & A:
- How To Connect Two Different Network Segments Using A Switch And A Router?Best solution by Super User
- How do I compare two tables with the same column definitions in different schemas?Best solution by Database Administrators
- I want to find a friend who moved address..... how can i do it.Best solution by Yahoo! Answers
- How do I find the number to a lost U.S. passport?Best solution by Yahoo! Answers
- Where can I find a under table job in Plainfield New Jersey?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.