Substitute to GROUP BY function
Hi All,
I really need a help on this thing. Most of us are aware about the group by function in Oracle. Do we have a substitute ( not necessarily a single line command) to it in Unix?
Let me put it this way.
I have a file whose content is like
file1-:
ID1,ID2,ID3,ID4,ID5
1,2,3,123,5
1,5,4,154,2
1,2,3,123,4
2,3,5,235,3
1,5,4,154,1
2,3,5,235,2
3,2,5,325,5
2,3,5,235,6
The first line is not the content of the file. Rather I put that to identify the the fields. ID3 is nothing but "ID1||ID2||ID3".
Now we need to sort the file1 based on ID4 and then sum up the ID4 values for the same ID3. This sum-ed up value will be ID5. And ID6 will be the number of records involved in the group.
My final output should be like
1,2,3,123,9,2
1,5,4,154,3,2
2,3,5,235,11,3
3,2,5,325,5,1
Is not this what the GROUP BY function performs in Oracle? If my words are confusing then sorry for that. But the i/p and o/p files are self explanatory. Ain't they?
Thanks in advance for any help.
Many regards,
Rinku..