我有一张如下表,
Table
Date1 Date2 Priority level
1/1/1970 10/31/2013 -1 A
12/1/2013 10/31/2014 -1 A
12/31/2013 1/31/2016 1 B
12/31/2012 10/31/2018 1 C
12/31/2012 10/31/2019 2 C
12/31/2012 12/31/9999 3 C
12/31/2011 12/31/9999 4 C
我需要根据级别和优先级找到重叠和偏移日期范围。结果
Date1 Date2 level
1/1/1970 10/31/2013 A
12/1/2013 10/31/2014 A
10/31/2014 1/31/2016 B
10/31/2013 12/1/2013 C
1/31/2016 10/31/2019 C
10/31/2019 12/31/9999 C
从视觉上看,这将给出以下内容:
A[---------]-------------------------------------------------------------------------------
A----------------[-----------------]-------------------------------------------------------
B---------------------[------------------]-------------------------------------------------
C--------[----------------------------------------]----------------------------------------
C--------[-------------------------------------------------]-------------------------------
C--------[--------------------------------------------------------------------------------]
C----[------------------------------------------------------------------------------------]
结果
A[---------]-------------------------------------------------------------------------------
A----------------[-----------------]-------------------------------------------------------
B----------------------------------[-----]-------------------------------------------------
C----------[-----]-------------------------------------------------------------------------
C-----------------------------------------[----------------]-------------------------------
C-----------------------------------------------------------[-----------------------------]