View previous topic :: View next topic |
Author |
Message |
djh Beginner
Joined: 25 Jul 2006 Posts: 3 Topics: 1
|
Posted: Wed Aug 11, 2010 7:52 am Post subject: SORT sets of records of which only first meets criteria |
|
|
Hi
it's been a while since I did more complicated sorts and I'd be obliged for some help. (While I could write a program to get the job done, I feel this should be also possible with a SORT/SPLICE operation. Just can't figure out how.)
My infile is already sorted by
1. personnel-id (cols. 4-9) and
2. record identifier (cols. 1-3)
For every personnel-id there is just one record of type 101, plus n records of other types. Information on the department is only contained in the type 101 records (cols 10-14). Other recordtypes for that same employee might contain other kinds of information in cols 10-14.
Now if this is the infile:
101 000001 12345
102 000001 xyz
103 000001 xyz
104 000001 xyz
105 000001 xyz
101 000002 99999
102 000002 xyz
102 000002 xyz
102 000002 xyz
105 000002 xyz
106 000002 xyz
101 000003 12345
102 000003 xyz
101 000004 99999
104 000004 xyz
105 000004 xyz
105 000004 xyz
101 000005 12345
103 000005 xyz
104 000005 xyz
109 000005 xyz
110 000005 xyz
I want all records for each employee in department 12345, not just the 101-record. Thus giving
101 000001 12345
102 000001 xyz
103 000001 xyz
104 000001 xyz
105 000001 xyz
101 000003 12345
102 000003 xyz
101 000005 12345
103 000005 xyz
104 000005 xyz
109 000005 xyz
110 000005 xyz
as outfile.
It's easy enough to skim the infile for 101-records which belong to dpt. 12345. That would give me a list of all the personnel-ids in that department. But then what?
Any help appreciated, thx very much in advance
Dirk |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
djh Beginner
Joined: 25 Jul 2006 Posts: 3 Topics: 1
|
Posted: Thu Aug 12, 2010 2:00 am Post subject: |
|
|
Thanks a lot, Kolusu! That was what I was looking for!
Best greetings, Dirk |
|
Back to top |
|
|
|
|