I have a requirement to know count based on some grouping.
I have 3 fields and I want to get the counts grouping these 3 fields.
For Eg:
Input file has data as below:
XX 0001 AAAAAA
XX 0002 AAAAAA
XX 0003 AAAAAA
XX 0004 AAAAAA
YY 0001 BBBBBB
YY 0002 BBBBBB
YY 0003 BBBBBB
ZZ 0001 CCCCCC
ZZ 0002 CCCCCC
ZZ 0003 CCCCCC
I am able to get the counts as below:
XX AAAAA 0000004
YY BBBBBB 0000003
ZZ CCCCCC 0000003
Means I am able to count by first and third fields i.e. XX and AAAAAA, YY and BBBBBB, ZZ and CCCCCC. But, my requirement bit changed to count based on the middle field also.
I want to group based on the second field but with specific range.
For Eg:
I want to get the counts individually between 1 and 2 inclusive , 3 and 4 inclusive. Means the output shoud be as below:
XX AAAAA 0000002 - for second field value between 1 and 2
XX AAAAA 0000002 - for second field value between 3 and 4
YY BBBBBB 0000002 - for second field value between 1 and 2
YY BBBBBB 0000001 - for second field value between 3 and 4
ZZ CCCCCC 0000002 - for second field value between 1 and 2
ZZ CCCCCC 0000001 - for second field value between 3 and 4
I tried to search in the forum to get this output. But, I couldn't find the result.