Re: Counting # of consecutive rows with specified value(s)?

From: François Beausoleil <francois(at)teksol(dot)info>
To: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Counting # of consecutive rows with specified value(s)?
Date: 2012-06-07 19:35:35
Message-ID: CF7DA474-660B-4EC4-B7E7-60A0C3BE6ABF@teksol.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Le 2012-06-06 à 22:20, Ken Tanzer a écrit :
>
> I can currently test whether someone has at least a specified number of consecutive absences with the query below, but it would be better to get the actual number.
>
> As a second question, what about getting the number of consecutive records for a set of values? (e.g., attendance_code IN ('ATTENDED','EXCUSED')
>
> Any ideas or suggestions? Thanks.

This is similar to the islands and gaps problem. Search for that on StackOverflow and you'll get it.

Bye!
François

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2012-06-07 19:48:29 Re: Missing row after update
Previous Message hubert depesz lubaczewski 2012-06-07 19:16:49 Problem with pg_upgrade 8.3 to 9.1.4 - clog missing?!