Re: Check set of date intervals

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: Check set of date intervals
Дата
Msg-id 20100527124515.GE6907@a-kretschmer.de
обсуждение исходный текст
Ответ на Check set of date intervals  (Anton Gavazuk <antongavazuk@gmail.com>)
Список pgsql-sql
In response to Anton Gavazuk :
> Hi Andreas,
> 
> great thanks for the response,

please, answer to the list, not to me, okay?


> 
> unfortunately function just tests every row  - it doesnt construct set of
> periods which would cover choosed period.

That's hard to achieve ... maybe you have to create a table with
contiguous periods. Somewhere i have found this code-snippet:

test=*# select * from t1;a
---- 1 2 3 4 6 7 810111213
(11 rows)

test=*# WITH RECURSIVE RecCols (LeftBoundary, Value) AS (SELECT a, a FROM t1 WHERE (a - 1) NOT IN (SELECT a FROM t1)
UNIONALL SELECT p.LeftBoundary, c.a FROM RecCols AS p, t1 AS c WHERE c.a = p.Value + 1) SELECT LeftBoundary, MAX(Value)
ASRightBoundary FROM RecCols   GROUP BY LeftBoundary   ORDER BY LeftBoundary;leftboundary | rightboundary
 
--------------+---------------           1 |             4           6 |             8          10 |            13
(3 rows)

Maybe that's the way you have to go ...



Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431  2EB0 389D 1DC2 3172 0C99


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

Предыдущее
От: "A. Kretschmer"
Дата:
Сообщение: Re: Check set of date intervals
Следующее
От: "Good, Thomas"
Дата:
Сообщение: Question about slow queries...