« jQuery Gallery with Flikr hooks | Main | Querying OWL »

May 20, 2010

Overlapping dates revisited

select distinct s1.resident_slot_id 

from eclub.resident_slot s1,  eclub.resident_slot s2 

where 

s1.start_time < s2.end_time 

and 

s2.start_time < s1.end_time 

and 

s1.resident_id = s2.resident_id 

and 

s1.resident_slot_id != s2.resident_slot_id 

and s2.expired_date is null and s1.expired_date is null

Tags: PostgreSQL

Posted by pj at May 20, 2010 04:21 PM

Comments