Need Help with Awk Command

Hi All,
I have requirement where I have 4 columns in flat file.
Column names are P,Q,X,Y
in column X I have 3 diff value for records say A,B,C
Now Lets say there are 100 records in file , My output should be look like this

SUMMARY|Column X|A|50
SUMMARY|Column X|B|30
SUMMARY|Column X|C|20

50, 30 and 20 are the number of records present for each disnnt value of A.B and C
Need help in how I can achive this in AWK.

Hi,
Just to be sure, could you paste some examples lines from input file ?

The code should be something like

{
   # X = column number
   array[$X]++;
}
END {
  for ( x in array ) {
    printf("SUMMARY|Column X|%s|%d\n",x,array[x]);
  }
}
awk -F\| '{a[$3]++}END{for(i in a) print "SUMMARY|Column X|"i"|"a}' file

Thanks

please provide sample input

sanranad,
Here's the code if you wanted to group by column's P, Q and X (not just column X as you requested) if your input file should have different values for column P and Q as well. The output from this does not inlcude the 4th column Y from the input file which I assume you don't want since it's not in your output file example (again, need to post sample input file).

awk -F'|' '{arr[$1 "|" $2 "|" $3]++} END {for (i in arr) print i"|"arr}' input.file