我正在努力完成以下任务。我有一张这样的桌子:
+-----+-------------------------+-------------------------+-------------------------+-------------------+-------------------+-------------------+
| Id | Assigned Date | Assigned Starttime | Assigned Endtime | lesson_subject_id | lesson_teacher_id | lesson_classes_id |
+-----+-------------------------+-------------------------+-------------------------+-------------------+-------------------+-------------------+
| 116 | 2016-03-03 00:00:00.000 | 1900-01-01 13:15:00.000 | 1900-01-01 14:00:00.000 | SU_SK | Adlberger | CL_HEB 15/I B |
| 112 | 2016-03-03 00:00:00.000 | 1900-01-01 13:15:00.000 | 1900-01-01 14:00:00.000 | SU_SK | Jakob | CL_HEB 15/I A |
| 113 | 2016-03-03 00:00:00.000 | 1900-01-01 14:15:00.000 | 1900-01-01 15:00:00.000 | SU_SK | Jakob | CL_HEB 15/I A |
| 117 | 2016-03-03 00:00:00.000 | 1900-01-01 14:15:00.000 | 1900-01-01 15:00:00.000 | SU_SK | Adlberger | CL_HEB 15/I B |
| 118 | 2016-03-03 00:00:00.000 | 1900-01-01 15:15:00.000 | 1900-01-01 16:00:00.000 | SU_SK | Adlberger | CL_HEB 15/I B |
| 114 | 2016-03-03 00:00:00.000 | 1900-01-01 15:15:00.000 | 1900-01-01 16:00:00.000 | SU_SK | Jakob | CL_HEB 15/I A |
| 115 | 2016-03-03 00:00:00.000 | 1900-01-01 16:15:00.000 | 1900-01-01 17:00:00.000 | SU_SK | Jakob | CL_HEB 15/I A |
| 119 | 2016-03-03 00:00:00.000 | 1900-01-01 16:15:00.000 | 1900-01-01 17:00:00.000 | SU_SK | Adlberger | CL_HEB 15/I B |
+-----+-------------------------+-------------------------+-------------------------+-------------------+-------------------+-------------------+
如您所见,有一些条目同时开始和结束。
我需要做的是将单元格合并在一起并删除不必要的行。
结果应该是这样的
+-----+-------------------------+-------------------------+-------------------------+-------------------+-------------------+----------------------------------+
| Id | Assigned Date | Assigned Starttime | Assigned Endtime | lesson_subject_id | lesson_teacher_id | lesson_classes_id |
+-----+-------------------------+-------------------------+-------------------------+-------------------+-------------------+----------------------------------+
| 116 | 2016-03-03 00:00:00.000 | 1900-01-01 13:15:00.000 | 1900-01-01 14:00:00.000 | SU_SK | Adlberger, Jakob | CL_HEB 15/I A, CL_HEB 15/I B |
| 113 | 2016-03-03 00:00:00.000 | 1900-01-01 14:15:00.000 | 1900-01-01 15:00:00.000 | SU_SK | Adlberger, Jakob | CL_HEB 15/I A, CL_HEB 15/I B |
| 118 | 2016-03-03 00:00:00.000 | 1900-01-01 15:15:00.000 | 1900-01-01 16:00:00.000 | SU_SK | Adlberger, Jakob | CL_HEB 15/I A, CL_HEB 15/I B |
| 115 | 2016-03-03 00:00:00.000 | 1900-01-01 16:15:00.000 | 1900-01-01 17:00:00.000 | SU_SK | Adlberger, Jakob | CL_HEB 15/I A, CL_HEB 15/I B |
+-----+-------------------------+-------------------------+-------------------------+-------------------+-------------------+----------------------------------+
有什么想法可以实现这一目标吗?我在 Sql Server 2008 R2
问候卢卡斯