我似乎无法弄清楚这个查询。我需要将时间连续状态的行合并为一个状态。
这个问题与这里找到的问题类似,除了我使用的是Oracle 10而不是SQL Server: 当一个的结束时间是另一个的开始时间时合并行
示例数据:
name start_inst end_inst code subcode
Person1 9/12/2011 10:55 9/12/2011 11:49 161 50
Person1 9/12/2011 11:49 9/12/2011 11:55 107 28
Person1 9/12/2011 11:55 9/12/2011 12:07 161 50
Person1 9/12/2011 12:07 9/12/2011 12:26 161 50
Person1 9/12/2011 12:26 9/12/2011 12:57 161 71
Person1 9/12/2011 12:57 9/12/2011 13:07 161 71
Person1 9/12/2011 13:07 9/12/2011 13:20 52 50
Run Code Online (Sandbox Code Playgroud)
我想得到以下输出:
name start_inst end_inst code subcode
Person1 9/12/2011 10:55 9/12/2011 11:49 161 50
Person1 9/12/2011 11:49 9/12/2011 11:55 107 28 …Run Code Online (Sandbox Code Playgroud)