× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Dave,

This is from an email from Craig:

Below is a list of SQL statements for accurately finding/deleting 
duplicates.  I have been having to do this more often recently and I was 
constantly fiddling with the SQL statements to make them work accurately 
in the test library and then sweating profusely on production data.  I 
hope none of you have to go through the same struggle.  Darren had the 
bulk of the statements correct but with a little addition, they now work 
for all cases I used.  The inspiration for these came from bits off the 
internet.  Darren has the first two documented here ->  under "SQL" then 
"Finding or deleting duplicates".  He has some other good programing tips 
there.  Excellent!  The last statement may be documented in the future but 
it is up to Darren.  The last statement is seen more readily on the 
internet.

1. Here is the SQL statement for selecting just the duplicates:
Select RRN(A) From MyLib/MyFile A Where RRN(A) in
(Select RRN(B) From MyLib/MyFile B, Mylib/Myfile C
    Where B.LastName = C.LastName and RRN(B) > RRN(C))

Note: You can add things like "A.*, RRN(A)" to the select to show all 
fields in the file plus the relative record number or "Count(*)" for a 
count.

2. Here is the SQL statement for deleting just the duplicates:
Delete From MyLib/MyFile A Where RRN(A) in
(Select RRN(B) From MyLib/MyFile B, Mylib/Myfile C
    Where B.LastName = C.LastName and RRN(B) > RRN(C))

3. Then there is the SQL statement for selecting the duplicates summarized 
into one group (record) per occurence.
For example, getting a count or list of invoices that are duplicated 
without looking at the duplicated entries.
With Z as ( 
  Select LastName From MyLib/MyFile 
  group by LastName Having Count(*) > 1
  ) Select Count(*) From Z 

You just use that select by itself for a list instead of a count.
Note: Separate different key values of a where with "and/or" but separate 
groups and selection fields by commas.  Don't forget the prefixes.

Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.