× 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.



On Mon, Oct 5, 2015 at 11:07 AM, Alan Shore <ashore@xxxxxxxx> wrote:
This is driving me nuts (I know - not that far to drive)
I used the following sql to delete duplicate records in a file
delete from file01 A where rrn(A) in
(select RRN(B) from file01 B, file01 C where
b.IITEM = c.IITEM and RRN(B) > RRN(C))

Preferably, you shouldn't be thinking in terms of RRN at all if you
are using SQL. As such, my recommendation is to not use SQL and just
write a quick RPG program to do it. (Simply read all the records in
keyed order and get rid of anything that's the same as the previous
record.)

I know deletion of duplicates in SQL must be a common question, so I
just spent some time Googling around. The profusion of different
approaches, even if you narrow yourself to DB2, strongly suggests to
me that lots of people are getting this wrong when they try to do it
in SQL. I'm sure there are some who are getting it right, but in the
time it takes for you to sift through and find the right answer(s),
you could have written and run the RPG program already.

John Y.

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.