Analytic type functionality, matching patters in a column then increment an integer

Поиск
Список
Период
Сортировка
От Henry Drexler
Тема Analytic type functionality, matching patters in a column then increment an integer
Дата
Msg-id CAAtgU9TcfJN2mPFjTLcZvYxC6CF20i7U8rSsXH5-wTfQGVKSgw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Analytic type functionality, matching patters in a column then increment an integer
Список 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 по дате отправления:

Предыдущее
От: Leif Biberg Kristensen
Дата:
Сообщение: I/O error on data file, can't run backup
Следующее
От: Tom Lane
Дата:
Сообщение: Re: I/O error on data file, can't run backup