I am not at all sure about your Input_file and expected output. As you are saying column 1 and column 2 should be common then it shouldn't be that count which you have posted.
awk -F"|" '{A[$1 FS $2]++} END{for(i in A){print A FS i}}' Input_file
Above takes field 1st and field 2nd as an index into array. If your requirements are different then please post complete conditions with expected results.
Thank you Ravinder for your response. Sorry if I question is not clear.
Condition 1 - Unique value of column one which are 3330690 and 0640829
Condition 2 - Unique value of column one 3330690 is associated with 2 distinct value of column 2 which are 373846 and 373847. The unique value of column 1 which is 0640829 is associated with unique value of column 2 which is 459725.
Hence output is expected as below
2 3330690
1 459725
Hope this clarifies.
---------- Post updated at 08:48 PM ---------- Previous update was at 06:11 PM ----------
Thank you RudiC. This worked perfectly. Now I am trying to understand this piece of code.
Can you please help explaining the code?
If the index constructed from $1 and $2 does not exist in the temp array T, its a new combination, and the counter for $1 is incremented. When the input file ends, all these counters and the corresponding $1 values are printed.
More detailed:
For the first occurrence of the $1,$2 combination, T[$1,$2] doesn't exist, so !T[$1,$2] is true, and the counter C[$1] is incremented. Due to the increment of T , the next time the combination is encountered, nothing will happen. C[$1] thus counts up the different $2 s for every single $1 . In the end, the count for every single $1 is printed.