Assuming I have the following table:
date version
2015-02-01 v1
2015-02-02 v1
2015-02-03 v1
2015-02-04 v1
2015-02-02 v2
2015-02-03 v2
2015-02-08 v1
2015-02-09 v1
My query shall group dates in such way I get this result:
datefrom dateto version
2015-02-01 2015-02-04 v1
2015-02-08 2015-02-09 v1
2015-02-02 2015-02-03 v2
I tried something with
LEAD(date) OVER(PARTITION BY version ORDER BY date)
but it did not really pay off since I cannot group the "bins" of dates. I want to group each subsequent date into on bin allowing no date gap.