Re: select by streak

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: select by streak
Дата
Msg-id 00ac01c0fa34$a9948460$1001a8c0@archonet.com
обсуждение исходный текст
Ответ на select by streak  (Joseph Shraibman <jks@selectacast.net>)
Список pgsql-sql
From: "Joseph Shraibman" <jks@selectacast.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



В списке pgsql-sql по дате отправления:

Предыдущее
От: Jie Liang
Дата:
Сообщение: plsql in 7.1
Следующее
От: "Richard Huxton"
Дата:
Сообщение: Re: Extracting date from epoche