work on the two tables
How to put this in SQL.
The dates of 3 settlement and 3 dates of eviction (half may be empty, i.e. unknown when evicted).
Example: (2007-09-01 villages), 2007-10-01 (settlements), 2008-09-01 (settlements), 2010-09-01 (outs), empty date(s), 2014-06-30(outs)
QuestionHow do we make 2-day settlements comparable to 1-settlements, then 3-day settlements compare to 2-day evictions, etc?
i.e. each next settlement date compares with the previous eviction
If I understood you correctly in table 2 of the field date1 settlements date2 evictions You need to use the table three times in your request. example
select * from table t1, table t2, table t3 where t1.tt=t2.tt and t1.tt=t3.tt and (t1.date1>t2.date2 or t2.date2 is null) and t2.date1>t3.date2 or t3.date2 is null)