Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux