我有一个如下所示的 Oracle 11.2 表。
MSG_ID JOB_ID STATUS CREATION_DATE
1 101 SUB 03/30/2011 14:39:52
2 101 SUB 03/30/2011 14:44:37
3 101 RCVD 03/31/2011 14:41:49
4 101 ACCPTD 03/31/2011 14:59:51
5 101 DESIGN 03/31/2011 17:44:37
6 101 REVIEW 03/31/2011 17:44:50
7 101 (null) 04/01/2011 07:51:41
8 101 REJECTED 04/01/2011 07:56:56
9 101 (null) 04/01/2011 16:36:19
10 101 REVIEW 04/01/2011 16:43:49
11 101 APPROVED 04/04/2011 07:55:45
12 101 (null) 04/04/2011 08:14:23
13 101 REJECTED 04/04/2011 14:46:17
14 101 REVIEW 04/04/2011 14:50:50
15 101 (null) 04/04/2011 14:51:27
16 101 REVIEW 04/04/2011 14:57:50
17 101 (null) 04/04/2011 15:34:50
18 101 APPROVED 04/04/2011 15:41:21
19 101 (null) 04/04/2011 15:41:23
20 101 REJECTED 04/04/2011 15:41:24
21 101 REVIEW 04/04/2011 16:07:52
22 101 (null) 04/05/2011 08:50:35
23 101 APPROVED 04/05/2011 10:54:51
24 101 PROD 04/05/2011 11:08:50
25 101 COMPLET 04/06/2011 20:09:49
我正在尝试对相邻(相对于创建日期)消息状态和每个唯一状态组合之间的时间间隔进行分组。可以忽略空状态。结果如下所示。
JOB_ID FROM_STATUS TO_STATUS TIME_INTERVAL
101 SUB RCVD sum of time intervals
101 RCVD ACCPTD sum of time intervals
101 ACCPTD DESIGN sum of time intervals
101 DESIGN REVIEW sum of time intervals
101 REVIEW REJECTED sum of time intervals
101 REJECTED REVIEW sum of time intervals
101 REVIEW APPROVED sum of time intervals
101 APPROVED REJECTED sum of time intervals
101 APPROVED PROD sum of time intervals
101 PROD COMPLETE sum of time intervals
有人可以帮助执行此操作所需的 SQL。
先感谢您