×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




While it may not be star performer, something like this ought to do it:

DELETE FROM file a 
WHERE RRN(a) NOT IN 
( 
  SELECT keeper 
  FROM 
    ( 
      SELECT MIN(RRN(b)) as keeper, 
             Account_Number, Order_Date, Sequence_Number
      FROM file b                                          
      GROUP BY Account_Number, Order_Date, Sequence_Number
    ) t1
)

HTH

Elvis

-----Original Message-----
Subject: SQL Delete question

Greetings!

I have a file that, among other fields, has Account_Number, Date, Sequence
number.

In the file there are multiple occurrences of those three fields.  Example

Account_Number     Date    Sequence_number
            1             20061206           01
            1             20061206           01
            1             20061206           01
            1             20061206           02
            1             20061206           02
            1             20061206           02
            1             20061206           03
            1             20061206           03
            1             20061206           03
            1             20061206           04
            1             20061206           04
            1             20061206           04

What I am looking for is a way to delete all but one occurrence of the
repeated data to get a file that looks like;

Account_Number     Date    Sequence_number
            1             20061206           01
            1             20061206           02
            1             20061206           03
            1             20061206           04


Is this something I can do with SQL?  If so, what would the SQL statement
look like?

Jim



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