Re: [SQL] Merge overlapping time-periods

2011-06-15 Thread Oliveiros d'Azevedo Cristina
JOIN mytable b ON a."ID" = b."ID" AND (( ((a."BEG",a."END") OVERLAPS (b."BEG",b."END")) OR ((a."BEG" - b."END") = 1)) AND (a."BEG" <> b."BEG") AND (b."END" <> a."END&

Re: [SQL] Merge overlapping time-periods

2011-06-15 Thread Oliveiros d'Azevedo Cristina
Howdy, Marcel, In the example output you provided the ID = 2 should have just one record...Ain't I right? Best, Oliveiros - Original Message - From: Jira, Marcel To: 'pgsql-sql@postgresql.org' Sent: Wednesday, June 15, 2011 4:23 PM Subject: [SQL] Merge o

Re: [SQL] Merge overlapping time-periods

2011-06-15 Thread F. BROUARD / SQLpro
I write a paper on this topic comparing queries for PG, SQL Server and MySQL. Can you read french ? http://blog.developpez.com/sqlpro/p9821/langage-sql-norme/agregation-d-intervalles-en-sql-1/ The worst query is the RECURSIVE one ! A + Le 15/06/2011 17:23, Jira, Marcel a écrit : Hi! Althou

[SQL] Merge overlapping time-periods

2011-06-15 Thread Jira, Marcel
Hi! Although I try for some time, I am not able to write an SQL-Query that can do the following: I have a very big table (let's call it "mytable") with information like this: ID BEG END 1 2000-01-01 2000-03-31 1 2000-04-01 2000-05-31 1 2000-04-15 2000-07-31 1 2000-09-01