How To Find Epsnepal Klt Result?

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

Was this solution helpful to you?

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

Just Added Q & A:

Find solution

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.