Hi,

It is faster to use RDB$DB_KEY to find and delete duplicates.

See more details here
http://ib-aid.com/en/articles/how-to-find-and-delete-duplicate-records-in-firebird-database/

Regards,
Alexey Kovyazin
IBSurgeon



I had finally figured it out just before your reply

SELECT DISTINCT P.SOC_SEC_NO,
(SELECT COUNT(*)
FROM PERSON P2
WHERE P2.SOC_SEC_NO = P.SOC_SEC_NO) AS CNT
FROM PERSON P
WHERE P.SOC_SEC_NO IS NOT NULL
GROUP BY 1
HAVING (SELECT COUNT(*)
FROM PERSON P3
WHERE P3.SOC_SEC_NO = P.SOC_SEC_NO) > 1

This appears to work. See anything that I should change?

-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com]
Sent: Thursday, February 04, 2016 1:25 PM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] How do find duplicates in a table?

04.02.2016 20:09, 'stwizard' stwiz...@att.net [firebird-support] wrote:
> How do I form a SQL Select statement that will return which records in
> my PERSON table have duplicate SOC_SEC_NO.

RTFM GROUP BY, HAVING, COUNT().

--
WBR, SD.



  • [firebird-sup... 'stwizard' stwiz...@att.net [firebird-support]
    • Re: [fir... Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
      • RE: ... 'stwizard' stwiz...@att.net [firebird-support]
        • ... 'Woody' woody-...@gt.rr.com [firebird-support]
          • ... 'stwizard' stwiz...@att.net [firebird-support]
            • ... 'Edward Mendez' emendez...@nc.rr.com [firebird-support]
        • ... Alexey Kovyazin a...@ib-aid.com [firebird-support]
    • RE: [fir... Peterson Seridonio loukinh...@hotmail.com [firebird-support]
    • Re: [fir... Svein Erling Tysvær setys...@gmail.com [firebird-support]

Reply via email to