我需要报告每个支持组的事件处于待处理/已分配/进行中状态的持续时间。数据存储在两个表中;ASSIGNMENT_LOG 保存支持组之间分配转移的历史记录,以及 STATUS_LOG 保存事件状态更改的历史记录。
附件是一个事件的样本数据。请查看并建议如何进行。
WITH slog AS (
select '000000000266702' REQUEST_ID, 'INC000000128540' INCIDENT_NUMBER, 'Assigned' INCIDENTSTATUSTEXT, 1431348757 TIMESTAMPSTART,'11.5.2015 15:52:37' STARTTEXT, 1432033832 TIMESTAMPEND,'19.5.2015 14:10:32' ENDTEXT from dual
union
select '000000000268200','INC000000128540','In Progress',1432033832,'19.5.2015 14:10:32',1432034915,'19.5.2015 14:28:35' from dual
union
select '000000000268205','INC000000128540','Pending',1432034915,'19.5.2015 14:28:35',1432034927,'19.5.2015 14:28:47' from dual
union
select '000000000268206','INC000000128540','Assigned',1432034927,'19.5.2015 14:28:47',1432034970,'19.5.2015 14:29:30' from dual
union
select '000000000268207','INC000000128540','Pending',1432034970,'19.5.2015 14:29:30',1432034988,'19.5.2015 14:29:48' from dual
union
select '000000000268208','INC000000128540','In Progress',1432034988,'19.5.2015 14:29:48',null,null from dual
),
alog AS(
select 'INC000000128540' INCIDENT_NUMBER, '000000000103677' REQUEST_ID, 'Helpdesk' ASSIGNED_GROUP, 1431348757 TIMESTAMPSTART, 1431434286 TIMESTAMPEND, '11.5.2015 15:52:37' STARTTEXT,'12.5.2015 15:38:06' ENDTEXT from dual
union
select 'INC000000128540','000000000103816','L1',1431434286,1432033740,'12.5.2015 15:38:06','19.5.2015 14:09:00' from dual
union
select 'INC000000128540','000000000104352','L2',1432033740,1432033777,'19.5.2015 14:09:00','19.5.2015 14:09:37' from dual
union
select 'INC000000128540','000000000104353','L1',1432033777,1432034927,'19.5.2015 14:09:37','19.5.2015 14:28:47' from dual
union
select 'INC000000128540','000000000104354','L2',1432034927,1432034980,'19.5.2015 14:28:47','19.5.2015 14:29:40' from dual
union
select 'INC000000128540','000000000104355','L1',1432034980,null,'19.5.2015 14:29:40',null from dual
)
SELECT
alog.*, slog.*
from alog, slog
where alog.incident_number = slog.incident_number
order by alog.request_id, slog.request_id