Gerrit-Jan Linker
|
Determine date overlap. Suppose you have a table with a start_date and end_date. If you have the requirement to determine whether there is overlap in the periods defined by the start_data and end_dates you can use the following approach. With the following query overlap can be determined. If rows are returned, periods are in overlap. select * from my_table a , my_table b where b.start_date < a.end_date and b.end_date > a.start_date and not b.rowid = a.rowid In this query we make a cartesian product of the rows in the table. With the condition "not b.rowid = a.rowid" we ensure that a row is compared with itself. What remains is a combination of all the other possible rows.
|