View previous topic :: View next topic
|
Author |
Message |
Mahua Mitra
New User
Joined: 26 Apr 2007 Posts: 49 Location: Delhi
|
|
|
|
Hi
I have a file. The file has to compare three columns(C1, C2, C3) of the records. If the value of C1 and C2 are same, then have to compare C3 (date field). The row/rows having maximum value of C3 (value of C3 should be less/equal to than current date), such rows have to be written in the output file.
Sample input file
Code: |
C1 C2 C3 (dd/mm/yyyy) C4 C5
100 10 10/04/2007 a b
100 10 10/04/2007 c d
100 10 09/04/2007 e f
100 20 09/04/2007 g h
100 20 08/04/2007 i j
100 20 07/04/2007 k l
100 30 09/04/2007 m n
100 30 09/04/2007 o p
200 10 10/04/2007 q r
200 10 10/04/2007 s t
200 10 08/04/2007 u v
200 20 10/04/2007 w x
300 40 10/04/2007 y z
300 50 10/04/2007 0 1
300 60 10/04/2007 2 3
300 60 09/04/2007 4 5
300 60 08/04/2007 6 7 |
Required output
Sample input file
Code: |
C1 C2 C3 (dd/mm/yyyy) C4 C5
100 10 10/04/2007 a b
100 10 10/04/2007 c d
100 20 09/04/2007 g h
100 30 09/04/2007 m n
100 30 09/04/2007 o p
200 10 10/04/2007 q r
200 10 10/04/2007 s t
200 20 10/04/2007 w x
300 40 10/04/2007 y z
300 50 10/04/2007 0 1
300 60 10/04/2007 2 3 |
Can anyplease please let me know, will this be possible thorugh a SORT step. If yes, what will specified in the SORT card.
Thanks |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
I can't make any sense out of what you show for the example vs what you say you want.
Quote: |
the value of C1 and C2 are same |
But none of the records in your example have the same value for C1 and C2.
Quote: |
then have to compare C3 (date field). |
Compare C3 to what?
Quote: |
The row/rows having maximum value of C3 |
Maximum of C3? Relative to what?
Quote: |
value of C3 should be less/equal to than current date) |
I don't understand how this fits in.
You need to do a much better job of explaining the "rules" for what you want to do and how they relate to your example before anyone can help you. |
|
Back to top |
|
|
shrivatsa Warnings : 1 Active User
Joined: 17 Mar 2006 Posts: 174 Location: Bangalore
|
|
|
|
Frank,
He is comparing C1 & C2 of First Row with C1 and C2 of 2nd Row.
If the above condition is true then comare dates of First Row and 2nd Row i.e C3.. Write out the highest date rows in the ouput file. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Shrivatsa,
Thanks. Now that you mention it, I think you're right that he's comparing C1 and C2 between records rather than in each record.
Mahua,
I still don't understand how this statement fits in to all of this:
Quote: |
value of C3 should be less/equal to than current date |
Please explain.
Also, what is the RECFM and LRECL of the input file, and the starting position, length and format of C1, C2 and C3? |
|
Back to top |
|
|
|