Number of Consecutive Occurences

:b:
Hi Folks,
I have a requirement to find the number of consecutive occurences based on month. Here is the below sample of my requirement.

I have say four columns

CARUSERNAME BRAND_CODE MONTH YEAR

Below is sample Data

John|C|JAN|2013
Tim|C|FEB|2013
Tom|C|Mar|2013
Ron|C|Apr|2013
Phil|C|Dec|2013
Linda|C|Mar|2013
Dave|D|Apr|2013
Greg|D|May|2013

Like above I have a dataset containing 50 million records.

The output of my report should be

Number of ConsecutiveMonths | Brand |
C D
2 | 1 -
3 | - -
4 | - 1

Is there a way it can be programmed in unix?
:b:

What cant you do or what have you done so far?

Not clear. Explain way more.

I have attached the report sample for better understanding

The report sample that you attached does not provide better understanding. It doesn't contain the same data as your other sample (not even the same fields).

The data in message #1 in this thread seems to be sorted with the key: Increasing alphanumeric order of BRAND_CODE. The other fields do not appear to be sorted. There are no two records with the same CARUSERNAME. There is no indication of what the values in the table mean.

The data in the attachment in message #4 in this thread seems to be sorted with the keys: Increasing alphanumeric order of Brand, and either increasing calendar order of Month or decreasing alphanumeric order of Name. The entries in the output table seem to be arranged by groupings of Brand and Name. You seem to say that March, April, and June are three consecutive months (what happened to May)?

If you can't give us a clear description (in English) describing how the data is to be processed and a clear statement and corresponding example of what output you're trying to produce; we can't help.