[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference ilbbak::ibi_focus

Title:FOCUS, from INFORMATION BUILDERS
Moderator:ZAYIUS::BROUILLETTE
Created:Thu Feb 19 1987
Last Modified:Mon May 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:615
Total number of notes:1779

460.0. "selecting duplicate records" by CSLALL::COLBERT () Fri Sep 20 1991 14:01

    How does one select duplicate fields?
    
    Print all part numbers that appear on file more than 1 time.
    
    
    
T.RTitleUserPersonal
Name
DateLines
460.1define a dupe fieldKAHALA::FOREMANNothings Impossible, you just run out of timeFri Sep 20 1991 16:1512
    Well, I guess one way to do it would be ...
    
    Assuming the file is sorted in part-number order
    Define a field DUP_FLAG/A1 = IF PART_NUMBER EQ LAST PART_NUMBER THEN
                                 'Y' ELSE 'N';
    
    Then you could print all the part_numbers with a DUP_FLAG of 'Y'.
    
    If you'd expect more than 2 records for each part you'd have to use
    sum to just print the duplicate parts once on the report.
    
    Sharon
460.2Maybe I missed somethingCSLALL::COLBERTFri Sep 20 1991 16:445
    I gave this a try, but it still select all records.
    
    I defined the new field then 
    Print....
    IF newfield eq 'Y'
460.3Always miss something in translationKAHALA::FOREMANNothings Impossible, you just run out of timeFri Sep 20 1991 16:553
    Yup, that's what I meant to say. Guess I didn't explain it well enough.
    
    Sharon
460.4Not sure if you got it to work ..KAHALA::FOREMANNothings Impossible, you just run out of timeFri Sep 20 1991 17:2126
    Wasn't quite sure of the question, but that solution should have worked
    if you're sure the file you're reading is already sorted in part-number
    order.  Could it be that every part-number has a duplicate record ?
    
    Another way to do it so you could tell how many records each part
    number had ( if you need to know such a thing ) :
    
    DEFINE FILE PARTLIST
    REC_CNT/I6 = 1;
    END
    
    TABLE FILE PARTLIST
    SUM PART_NUMBER REC_CNT BY PART_NUMBER NOPRINT
    ON TABLE HOLD
    END
    
    To find the ones with more than one record ...
    
    TABLE FILE HOLD
    PRINT PART_NUMBER
    IF REC_CNT GT 1
    END
    
    Hope I answered the question this time.
    
    Sharon
460.5IF TOTAL does the trickRDGE88::KEEGAN_9Mon Sep 23 1991 03:4635
    If you just want to see a list of the duplicate records, then ...
    
    TABLE FILE X
    COUNT ENTRIES BY FIELDNAME
    IF TOTAL COUNT GT 1
    (ON TABLE SAVE AS LOOKUP)
    END
    
    will give a sorted list of values, with their frequency. 
    
    Should you wish to extract data based on this output then you'll need
    to include the ON TABLE SAVE line and use either
    
    TABLE FILE X                        }
    IF FIELDNAME EQ (LOOKUP)            } if LOOKUP 'relatively' small
    PRINT ...                           }
    
                                          
    or 
    
    DEFINE FILE X                            }
    OK/I1 = DECODE FIELDNAME(LOOKUP ELSE 1); }
    END                                      } if LOOKUP 'relatively' large
    TABLE FILE X                             } (see earlier notes on 
    IF OK EQ 0                               }  "look-up tables")
    PRINT ...                                }
    
    
    The result is the same as Sharon's, but gets there one step quicker.
    
    Kind regards,
    
    
    Paul K