Analytic type functionality, matching patters in a column then increment an integer - Mailing list pgsql-general

From Henry Drexler
Subject Analytic type functionality, matching patters in a column then increment an integer
Date
Msg-id CAAtgU9TcfJN2mPFjTLcZvYxC6CF20i7U8rSsXH5-wTfQGVKSgw@mail.gmail.com
Whole thread Raw
Responses Re: Analytic type functionality, matching patters in a column then increment an integer  (Richard Huxton <dev@archonet.com>)
List pgsql-general
I can do this in excel with vba, though due to the volume of data that is now impracticable and I am trying to move most of my logic into the query and db for analysis.

Looking at the analytic functions I see no way to carry values over the way they need to be.

Example column:

I have a column that evaluates to either tf,tt,ft,ff (true false matches).
tf means the start of a section, 
tt mans intermediary but in the good section
ft means the end of the section that needs to be marked.
ff is just ignored

so I can have
'evaluation'    
tf
tt
ft
ff
ff
tf
ft

and would like to have a column indicate like this:

'evaluation'    'indicator'
tf                     1
tt                     1
ft                      1
ff
ff
tf                      2
ft                      2
tf                      3
tt                      3
ft                      3
ff


I have tried rank() and some case statements though I can quite seem to get the sql to be aware across rows as shown in the desired indicator column noted above.

It seems like I am missing something that would we aware like that.  Any ideas?  Thanks in advance.

pgsql-general by date:

Previous
From: Leif Biberg Kristensen
Date:
Subject: I/O error on data file, can't run backup
Next
From: Tom Lane
Date:
Subject: Re: I/O error on data file, can't run backup