From: | Henry Drexler <alonup8tb(at)gmail(dot)com> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Analytic type functionality, matching patters in a column then increment an integer |
Date: | 2011-10-05 18:29:49 |
Message-ID: | CAAtgU9TcfJN2mPFjTLcZvYxC6CF20i7U8rSsXH5-wTfQGVKSgw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2011-10-05 18:42:00 | Re: I/O error on data file, can't run backup |
Previous Message | Leif Biberg Kristensen | 2011-10-05 18:13:46 | I/O error on data file, can't run backup |