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
8
10
11
12
13
(11 rows)
test=*# WITH RECURSIVE RecCols (LeftBoundary, Value) AS
(SELECT a, a FROM t1 WHERE (a - 1) NOT IN (SELECT a FROM t1)
UNION ALL SELECT p.LeftBoundary, c.a FROM RecCols AS p, t1 AS c WHERE c.a =
p.Value + 1)
SELECT LeftBoundary, MAX(Value) AS RightBoundary 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
--
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql