On 06/10/12 11:42, Anton Gavazuk wrote:
> Hi dear community,
> Have probably quite simple task but cannot find the solution,
> Imagine the table A with 2 columns start and end, data type is date
> start end
> 01 dec. 10 dec
> 11 dec. 13 dec
> 17 dec. 19 dec
> If I have interval, for example, 12 dec-18 dec, how can I determine
> that the interval cannot be fully covered by values from table A
> because of the gap 14-16 dec? Looking for solution and unfortunately
> nothing has come to the mind yet...
How about something like the following?
DROP TABLE IF EXISTS period;
CREATE TABLE period
id serial PRIMARY KEY,
INSERT INTO period (start_date, end_date) VALUES
slot (start_date, end_date) AS
p1.start_date = p2.end_date + 1
p3.start_date = s1.end_date + 1
AND p3.end_date > s1.end_date
s3.start_date <= '2012-12-01'
AND s3.end_date >= '2012-12-18'
In response to
pgsql-sql by date
|Next:||From: air||Date: 2012-10-06 12:47:46|
|Subject: How to make this CTE also print rows with 0 as count?|
|Previous:||From: Andreas Kretschmer||Date: 2012-10-06 07:55:21|
|Subject: Re: checking the gaps in intervals|