Re: maximum count of contiguous years
| От | Tim Landscheidt |
|---|---|
| Тема | Re: maximum count of contiguous years |
| Дата | |
| Msg-id | m3eiqogsj4.fsf@passepartout.tim-landscheidt.de обсуждение исходный текст |
| Ответ на | maximum count of contiguous years (gorsa <gorsa.1972@gmail.com>) |
| Ответы |
Re: maximum count of contiguous years
|
| Список | pgsql-general |
gorsa <gorsa.1972@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
В списке pgsql-general по дате отправления: