Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 1 of 1 total
Thread Listing Duplicate Rows
Fri, Dec 4 2009 4:06 PMPermanent Link

Richard Harding
Tim,

I have attached the backup file to demonstrate the following query.

SELECT ID, FName, MName, LName FROM Contacts C1
 WHERE  C1.FName ||C1.MName || C1.LName IN
    (SELECT C2.FName ||C2.MName || C2.LName
     FROM Contacts C2
     GROUP BY  FName, MName, LName
     HAVING COUNT(*) > 1)

However, it gives the result:

ID, FName, MName, LName
2 | Mary | A | Doe |     
4 | Mary | A | Doe |   

Add the word DISTINCT and the correct results appear.

SELECT DISTINCT ID, FName, MName, LName FROM Contacts C1
 WHERE  C1.FName ||C1.MName || C1.LName IN
    (SELECT C2.FName ||C2.MName || C2.LName
     FROM Contacts C2
     GROUP BY  FName, MName, LName
     HAVING COUNT(*) > 1)

Richard Harding



Attachments: TestDB Backup On 2009-12-05.EDBBkp
Image