I have a file(VB LRECL=71) with the following columns:
FIELD1= CHAR(6)
KEY1=CHAR(16)
TIMESTAMP=CHAR(26) DB2 Timestamp
KEY2=2 bytes Number
FIELD2=CHAR(16)
INPUT
----------
yyxxxxAAAAAAAAAAAAAAAA2009-01-01-01.00.00.0000000011234567890123456
yyxxxxAAAAAAAAAAAAAAAA2009-01-01-02.00.00.0000000011234567890123456
yyxxxxAAAAAAAAAAAAAAAA2009-01-01-00.00.00.0000000021234567890123457
yyxxxxBBBBBBBBBBBBBBBB2009-01-01-00.00.00.0000000011234567890123456
Records are grouped by KEY1.
If there are records with KEY2 =1 for a group, select the records with KEY2=1 for which TIMESTAMP has the lowest value.
If there are records with KEY2 !=1 for a group, select the record for which TIMESTAMP has the lowest value.
There are two groups(Unique KEY1): AAAAAAAAAAAAAAAA and BBBBBBBBBBBBBBBB.
For group AAAAAAAAAAAAAAAA, we have two records with KEY2=1. So we select the record that has the lowest TIMESTAMP.
For group BBBBBBBBBBBBBBBB, we do not have records with KEY2=1. So we select the record that has the lowest TIMESTAMP.
Our output will have two records, one for each group.
OUTPUT
----------
yyxxxxAAAAAAAAAAAAAAAA2009-01-01-01.00.00.0000000011234567890123456
yyxxxxBBBBBBBBBBBBBBBB2009-01-01-00.00.00.0000000011234567890123456
Can ICETOOL be used to produced this result?