|
|

楼主 |
发表于 2009/1/5 11:45:21
|
显示全部楼层
我有一段sql语句,我觉得很优化啊:
select
a.WONUM as a,
(SELECT DESCRIPTION FROM ALNDOMAIN WHERE DOMAINID='WOREQSTATUS' AND VALUE=A.WO17) AS b,
a.HDDELAYADV4NOTE as c,
(SELECT DISPLAYNAME FROM PERSON WHERE PERSONID=A.HDDELAYADV4USER) AS d,
a.HDDELAYADV4TIME as 仲裁申请时间, a.HDDELAYADV5NOTE as e,
(SELECT DESCRIPTION FROM DEPT WHERE DEPTNUM=A.HDDELAYADV4 ) AS f,
(SELECT DESCRIPTION FROM ALNDOMAIN WHERE DOMAINID='WOTH_JXZY' AND VALUE=A.HDDELAYADV5) AS g,
(SELECT DESCRIPTION FROM DEPT WHERE DEPTNUM=A.HDDELAYADV3 ) AS h
(SELECT DESCRIPTION FROM ALNDOMAIN WHERE DOMAINID='WOTH_JXZY' AND VALUE=A.WOPM1) AS i,
a.HDDELAYADV2NOTE as j ,
(SELECT DISPLAYNAME FROM PERSON WHERE PERSONID=A.HDDELAYADV5USER ) AS k from workorder a
WHERE (to_char(A.REPORTDATE,'yyyy-mm-dd hh24:mi:ss')
BETWEEN to_char(:startDate,'yyyy-mm-dd hh24:mi:ss') AND to_char(:endDate,'yyyy-mm-dd hh24:mi:ss'))
AND A.WORKTYPE='CM'
and A.HDDELAYADV5USER is not null
AND A.WOPM2 IS NOT NULL |
|