gorsa <gorsa.1...@gmail.com> wrote:

> [...]
> is there a select statement containing 'AND award_year BETWEEN 1994
> AND 2002' that could generate the following?
> scholar_id    consistent_yrs
>          1                 4
>          2                 5
>          3                 2

You could either do some wild fancy query where you parti-
tion the data by scholar_id, then by award_year, then filter
on the condition that the sum of award_year and RANK() (?)
less one equals the current award_year, find the maximum of
those, ...

  ... or you could just write a short function in your ap-
plication (or a set-returning PL/pgSQL function if your ap-
plication is dumb).

Tim


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to