Amazing!
Thanks a lot.

2011/5/18 Igor Tandetnik <itandet...@mvps.org>:
> select startGap, min(endGap) from
> (
>   select date(e1.endDate, '+1 day') startGap, date(e2.startDate, '-1
> day') endGap
>   from (select startDate, endDate from events
>         union all
>         select '' startDate, date('2011-01-01', '-1 day') endDate) e1,
>        (select startDate, endDate from events
>         union all
>         select date('2011-02-01', '+1 day') startDate, '' endDate) e2
>   where startGap <= endGap and startGap >= '2011-01-01' and endGap <=
> '2011-02-01'
>     and not exists (
>       select 1 from events where startDate between startGap and endGap
>         or endDate between startGap and endGap)
> )
> group by startGap;
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to