View previous topic :: View next topic
|
Author |
Message |
picus_mf Warnings : 1 New User
Joined: 09 Jun 2006 Posts: 52
|
|
|
|
Hi,
My requirement is to remove duplicates and sum the values corresponding to the duplicates.
Say for ex:
Emp ID Sal
E001 1000
E002 2000
E001 1000
E001 1000
E002 2000
E003 3000
I should get the output as
Emp ID Sal
E001 3000
E002 4000
E003 3000
How can I get this done?
Thanks. |
|
Back to top |
|
|
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
Hi,
Try below one
Code: |
SORT FIELDS=(1,4,CH,A)
SUM FIELDS=(6,4,ZD)
END
|
Regards
R KARTHIK |
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Hi,
To remove duplicates
adding a small change to the previous post
Code: |
SUM FIELDS=(6,4,ZD) ,XSUM
|
and declare the XSUM in the DD name |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Anand,
The card provided by Karthik looks ok. I don't think the OP was asking for an 'XSUM'. |
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Arun,
OP was saying Remove dups and summation so it needs to be there to have the duplicates in a seperate file |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
If you look at the input/output shown by OP - you'll find that sort-card from KARTHIK should suffice. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Anand,
The OP never mentioned about extracting the duplicates in a "separate file". Duplicate records automatically get removed during summation and that's what I understood. May be I am missing something here. We can wait for his response. |
|
Back to top |
|
|
picus_mf Warnings : 1 New User
Joined: 09 Jun 2006 Posts: 52
|
|
|
|
Thanks all,
Karthik's reponse has solved my issue. I do not want duplicates in a separate file. |
|
Back to top |
|
|
|