SELECT ROWNUM no1, t.*
FROM (
SELECT main.f_id, main.f_information, main.f_problemsourcename,
NVL (main.f_superviserenumber, 0) AS f_superviserenumber,
main.f_problemtype, main.f_code, main.f_moveend, main.f_moveendname,
main.f_problemlevelname,
(CASE
WHEN main.f_problemtype = 0
THEN '部件'
ELSE '事件'
END
) f_problemtypename,
( (CASE
WHEN main.f_problemtype = 0
THEN '部件'
ELSE '事件'
END)
|| ' '
|| main.f_classbigname
|| ' '
|| main.f_classsmallname
) AS problemtypename,
(main.f_streetname || ' ' || main.f_communityname || ' '
|| main.f_locatedetail
) AS loacatedetail,
main.f_classbigname, main.f_classsmallname, main.f_curoperationdate,
main.f_locatedetail, main.f_cursignuserid, main.f_oughtlastfeelbacktime,
main.f_verifyfeelbackcitymngpeople, main.f_problemlevelid,
main.f_dispatchuserid,
ROUND ( ( NVL (main.f_timelimit, 0) * 60
+ NVL (main.f_timeslowminute, 0)
+ NVL (main.f_timelapseminute, 0)
)
/ 60,
2
) timelimit,
tempTb.f_timelimit,
tempTb.Lastusetime2 usetime,
'督办' AS op, main.f_problemdiscription, main.f_dispatchdate, main.f_unitname,
main.f_unitid, main.f_communityid, main.f_streetid, main.f_classsmallid,
main.f_classbigid, main.f_problemsourceid
from oprt_s_main main,
(select oprt.F_ID, oprt.f_dispatchdate,
gettransacttime (oprt.f_dispatchdate,TO_DATE ('2009-5-5 17:14:02','YYYY-MM-DD HH24:MI:SS')) Beginusetime,
gettransacttime (oprt.f_dispatchdate,GetNormalFeelBackTime(TO_DATE ('2009-5-5 17:14:02','YYYY-MM-DD HH24:MI:SS'),120)) Lastusetime2,
ROUND ( ( NVL (oprt.f_timelimit, 0) * 60
+ NVL (oprt.f_timeslowminute, 0)
+ NVL (oprt.f_timelapseminute, 0)
)
/ 60,
2
) timelimit2,
( NVL (oprt.f_timelimit, 0) * 60
+ NVL (oprt.f_timeslowminute, 0)
+ NVL (oprt.f_timelapseminute, 0)
) f_timelimit from oprt_s_main oprt where oprt.f_moveend IN (SELECT f_code
FROM sys_s_state sta
WHERE sta.f_node IN (6))
) tempTb
where tempTb.f_timelimit between tempTb.Beginusetime and tempTb.Lastusetime2
and main.F_ID = tempTb.F_ID
union all
select * from
(SELECT f_id, f_information, f_problemsourcename,
NVL (f_superviserenumber, 0) AS f_superviserenumber,
f_problemtype, f_code, f_moveend, f_moveendname,
f_problemlevelname,
(CASE
WHEN f_problemtype = 0
THEN '部件'
ELSE '事件'
END
) f_problemtypename,
( (CASE
WHEN f_problemtype = 0
THEN '部件'
ELSE '事件'
END)
|| ' '
|| f_classbigname
|| ' '
|| f_classsmallname
) AS problemtypename,
(f_streetname || ' ' || f_communityname || ' '
|| f_locatedetail
) AS loacatedetail,
f_classbigname, f_classsmallname, f_curoperationdate,
f_locatedetail, f_cursignuserid, f_oughtlastfeelbacktime,
f_verifyfeelbackcitymngpeople, f_problemlevelid,
f_dispatchuserid,
ROUND ( ( NVL (f_timelimit, 0) * 60
+ NVL (f_timeslowminute, 0)
+ NVL (f_timelapseminute, 0)
)
/ 60,
2
) timelimit,
( NVL (f_timelimit, 0) * 60
+ NVL (f_timeslowminute, 0)
+ NVL (f_timelapseminute, 0)
) f_timelimit,
gettransacttime (f_dispatchdate,
TO_DATE ('2009-5-5 13:53:02',
'YYYY-MM-DD HH24:MI:SS'
)
) usetime,
'督办' AS op, f_problemdiscription, f_dispatchdate, f_unitname,
f_unitid, f_communityid, f_streetid, f_classsmallid,
f_classbigid, f_problemsourceid
FROM oprt_s_main
WHERE f_moveend IN (SELECT f_code
FROM sys_s_state
WHERE f_node IN (6)))
where USETIME > f_timelimit
) t
执行大约3分钟左右
FROM (
SELECT main.f_id, main.f_information, main.f_problemsourcename,
NVL (main.f_superviserenumber, 0) AS f_superviserenumber,
main.f_problemtype, main.f_code, main.f_moveend, main.f_moveendname,
main.f_problemlevelname,
(CASE
WHEN main.f_problemtype = 0
THEN '部件'
ELSE '事件'
END
) f_problemtypename,
( (CASE
WHEN main.f_problemtype = 0
THEN '部件'
ELSE '事件'
END)
|| ' '
|| main.f_classbigname
|| ' '
|| main.f_classsmallname
) AS problemtypename,
(main.f_streetname || ' ' || main.f_communityname || ' '
|| main.f_locatedetail
) AS loacatedetail,
main.f_classbigname, main.f_classsmallname, main.f_curoperationdate,
main.f_locatedetail, main.f_cursignuserid, main.f_oughtlastfeelbacktime,
main.f_verifyfeelbackcitymngpeople, main.f_problemlevelid,
main.f_dispatchuserid,
ROUND ( ( NVL (main.f_timelimit, 0) * 60
+ NVL (main.f_timeslowminute, 0)
+ NVL (main.f_timelapseminute, 0)
)
/ 60,
2
) timelimit,
tempTb.f_timelimit,
tempTb.Lastusetime2 usetime,
'督办' AS op, main.f_problemdiscription, main.f_dispatchdate, main.f_unitname,
main.f_unitid, main.f_communityid, main.f_streetid, main.f_classsmallid,
main.f_classbigid, main.f_problemsourceid
from oprt_s_main main,
(select oprt.F_ID, oprt.f_dispatchdate,
gettransacttime (oprt.f_dispatchdate,TO_DATE ('2009-5-5 17:14:02','YYYY-MM-DD HH24:MI:SS')) Beginusetime,
gettransacttime (oprt.f_dispatchdate,GetNormalFeelBackTime(TO_DATE ('2009-5-5 17:14:02','YYYY-MM-DD HH24:MI:SS'),120)) Lastusetime2,
ROUND ( ( NVL (oprt.f_timelimit, 0) * 60
+ NVL (oprt.f_timeslowminute, 0)
+ NVL (oprt.f_timelapseminute, 0)
)
/ 60,
2
) timelimit2,
( NVL (oprt.f_timelimit, 0) * 60
+ NVL (oprt.f_timeslowminute, 0)
+ NVL (oprt.f_timelapseminute, 0)
) f_timelimit from oprt_s_main oprt where oprt.f_moveend IN (SELECT f_code
FROM sys_s_state sta
WHERE sta.f_node IN (6))
) tempTb
where tempTb.f_timelimit between tempTb.Beginusetime and tempTb.Lastusetime2
and main.F_ID = tempTb.F_ID
union all
select * from
(SELECT f_id, f_information, f_problemsourcename,
NVL (f_superviserenumber, 0) AS f_superviserenumber,
f_problemtype, f_code, f_moveend, f_moveendname,
f_problemlevelname,
(CASE
WHEN f_problemtype = 0
THEN '部件'
ELSE '事件'
END
) f_problemtypename,
( (CASE
WHEN f_problemtype = 0
THEN '部件'
ELSE '事件'
END)
|| ' '
|| f_classbigname
|| ' '
|| f_classsmallname
) AS problemtypename,
(f_streetname || ' ' || f_communityname || ' '
|| f_locatedetail
) AS loacatedetail,
f_classbigname, f_classsmallname, f_curoperationdate,
f_locatedetail, f_cursignuserid, f_oughtlastfeelbacktime,
f_verifyfeelbackcitymngpeople, f_problemlevelid,
f_dispatchuserid,
ROUND ( ( NVL (f_timelimit, 0) * 60
+ NVL (f_timeslowminute, 0)
+ NVL (f_timelapseminute, 0)
)
/ 60,
2
) timelimit,
( NVL (f_timelimit, 0) * 60
+ NVL (f_timeslowminute, 0)
+ NVL (f_timelapseminute, 0)
) f_timelimit,
gettransacttime (f_dispatchdate,
TO_DATE ('2009-5-5 13:53:02',
'YYYY-MM-DD HH24:MI:SS'
)
) usetime,
'督办' AS op, f_problemdiscription, f_dispatchdate, f_unitname,
f_unitid, f_communityid, f_streetid, f_classsmallid,
f_classbigid, f_problemsourceid
FROM oprt_s_main
WHERE f_moveend IN (SELECT f_code
FROM sys_s_state
WHERE f_node IN (6)))
where USETIME > f_timelimit
) t
执行大约3分钟左右
解决方案 »
- 关于ORACLE存储过程中的循环语句
- 在RDBMS中通过哪些约束可以保证数据库的实体完整性及参照完整性
- 表数据批量更新问题,急急急!!!!!
- 请问各位:oracel 版本8.1.7.0.0支持execute immediate命令吗
- oracle数据库恢复的问题
- 新人安装oracle,不用手把手教,只希望老鸟们给点学习资料。谢谢您的回复
- 我也祝大家圣诞快乐!
- 请问如何把一个表里边的所有列名列出来?
- sqlplus连不上oracle的问题?
- SOS,我写的过程怎么在sqlplus里call时,出错为invalid呢?studioDBA里状态也为invalid,为呀?
- 关于oracle与ibatis结合的问题?
- 如何向对象表插入数据
要有这些数据才能分析啊
单纯一个SQL语句没办法优化的,最多看看是否语法上有待优化
把SELECT f_code FROM sys_s_state WHERE f_node IN (6)改成SELECT f_code FROM sys_s_state WHERE f_node=62:
把这个函数gettransacttime获取值的项去掉试试看,需要多长时间。3:建议把*换成具体的列。4:把in换成exists试试看(如果可以的话)。
http://blog.csdn.net/pathuang68/archive/2009/04/16/4084116.aspx