|
希望有人可以帮我看一下这个语句还可以怎么写的更好。先谢了
select JFDM, DLDM, JMJTotal from (
select a.SeniorCode as ZDM, a.JFCode as JFDM, b.GDDLDMEJ as DLDM, b.JMJTotal from
dlmis.tzdicjf a,
(select ZLDWDMC,GDDLDMEJ,sum(jmj) jmjtotal from
(select ZLDWDMC,GDDLDMEJ,pcmj jmj,GDDLDM from dlgis.mzdl500
union all select ZLDWDMC,GDDLDMEJ,pcmj jmj,GDDLDM from dlgis.mzdl2000
union all select ZLDWDMC,GDDLDMEJ,(pcmj-kcmj) jmj,GDDLDM from dlgis.mzdl10000
union all select ZLDWDMC,GDDLDMEJ,dzdlmj jmj,GDDLDM from dlgis.dzdl
union all select ZLDWDMC1 ZLDWDMC,GDDLDMEJ,xzdlmj1 jmj,GDDLDM from dlgis.xzdl
union all select ZLDWDMC2 ZLDWDMC,GDDLDMEJ,xzdlmj2 jmj,GDDLDM from dlgis.xzdl)
where InStr(GDDLDM,'K') = 0
group by ZLDWDMC,GDDLDMEJ) b
where a.JFCode like b.ZLDWDMC(+) ) c, dlmis.Tzdicdl d
where c.DLDM = d.wordfield79(+) and ZDM = (select wordfield58 from dlmis.tzdiczm where instr(wordfield59,Param101) > 0 and rownum = 1) order by JFDM;
Param101为输入字段。
[ 本帖最后由 supy 于 2006-6-21 10:53 编辑 ] |
|