PDA

View Full Version : Duplicate keys



T.Holt
01-01-1995, 02:00 AM
Ted, What does this program need to do? Have you considered SQL or Query? <font color="blue"> On Friday, May 29, 1998, 06:27 AM, Ted Sarah wrote: We have a file that contains the SSN as one of it's field. It is not a primary key, but a logical key, and so the data can be duplicated in many records. I am in the need of a quick and dirty program that can read this file and list certain fields in the record. I would write it myself, but I don't think it can be done in CL. But, I could be wrong. I can fuddel my way through an RPG program, but not write from scratch. Anyone got something like this? Ted</font>

Guest.Visitor
06-02-1998, 02:18 PM
On Tuesday, June 02, 1998, 10:53 AM, Ted Sarah wrote: The program needs to look at the key (SSN) and print any duplicate records, this could be 2,3, or more records. It does need to print the first as well as all following records. Needs to print name, ssn, dob, record key. <HR> In 400 SQL it takes two SELECT statements... First: select SSN, Count(*) from file_name group by SSN having Count(*) > 1 put the result table into an outfile; second join this outfile with table = file_name on SSN. IN mainframe DB/2 i think you can use a sub-select .. Bob Hamilton TEXAS BUSINESS SYSTEMS 736 Pinehurst Richardson, Texas 75080

T.Holt
06-03-1998, 06:26 AM
I think you could do it in one: select * from file_name where SSN in (select SSN from file_name group by SSN having count(*) > 1) <font color="blue"> On Tuesday, June 02, 1998, 02:18 PM, Bob Hamilton wrote: The program needs to look at the key (SSN) and print any duplicate records, this could be 2,3, or more records. It does need to print the first as well as all following records. Needs to print name, ssn, dob, record key. In 400 SQL it takes two SELECT statements... First: select SSN, Count(*) from file_name group by SSN having Count(*) > 1 put the result table into an outfile; second join this outfile with table = file_name on SSN. IN mainframe DB/2 i think you can use a sub-select .. Bob Hamilton TEXAS BUSINESS SYSTEMS 736 Pinehurst Richardson, Texas 75080</font>