Re: select by streak

From: "Richard Huxton" <dev(at)archonet(dot)com>
To: "Joseph Shraibman" <jks(at)selectacast(dot)net>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: select by streak
Date: 2001-06-21 09:29:24
Message-ID: 00ac01c0fa34$a9948460$1001a8c0@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

From: "Joseph Shraibman" <jks(at)selectacast(dot)net>

> Lets say I have a table like this:
>
> id int <== primary key
> ts timestamp
> name text
> status char
>
> status is G for good or B for bad. How do I do something like:
> SELECT name FROM mytable WHERE <last 3 entires in a row have status =
> 'B'> and <has been no good ones in the past week> ?

You're looking at a procedural solution here rather than SQL I'd suspect.
Either do this in your application or look into plpgsql or pltcl.

You might be able to do something with LIMIT and subselects (which I believe
cooperate in 7.1 - but test it) but it isn't going to be pretty.

HTH

- Richard Huxton

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message DI Hasenöhrl 2001-06-21 11:13:11 Problem by inserting rows in a table via function
Previous Message Richard Huxton 2001-06-21 09:25:51 Re: pl/pgsql question (functions)