按SQL中的日期顺序排列表分区

时间:2017-06-21 05:09:06

标签: sql sql-server

我有下表,需要输出

ID   Data From        To  
1    aa    2015-01-01  2015-01-05
1    aa    2015-01-05  2015-01-09
1    aa    2015-01-09  2015-01-15
1    bb    2015-01-15  2015-01-20
1    aa    2015-01-01  2015-01-05
1    aa    2015-01-05  2015-01-11
2    aa    2015-01-06  2015-01-10

预期输出

1    a    2015-01-01  2015-01-15
1    b    2015-01-15  2015-01-20
1    a    2015-01-01  2015-01-11
2    a    2015-01-06  2015-01-10

感谢。

0 个答案:

没有答案