Skip to content

Instantly share code, notes, and snippets.

Created June 15, 2012 10:57
Show Gist options
  • Save anonymous/2935860 to your computer and use it in GitHub Desktop.
Save anonymous/2935860 to your computer and use it in GitHub Desktop.
杭州正方教务管理系统,超级NB的SQL,你没看错这是一条查询。
select * from (select case when a.kcxzdm is null then '98' else a.kcxzdm end kcxzdm,a.kcxzmc,case when a.xfyq is null then 0 else to_number(a.xfyq) end xfyq ,b.xfh1,b.xfh2,to_number(to_number((case when a.xfyq is null then 0 else to_number(a.xfyq) end))-to_number(b.xfh1)) xfc from (select * from jxjhxfyqview where jxjhh=(select dqszj||zydm from xsjbxxb where xh='0407100522')) a left join (select kcxz,case when sum(xf1) is null then 0 else sum(xf1) end xfh1,case when sum(xf2) is null then 0 else sum(xf2) end xfh2 from (select kcdm,kcmc,kcxz,cj,xf,decode(floor(McjN/60),1,xf) xf1,decode(floor(McjN/60),0,xf) xf2 from (select a.*,b.xymc from (select a.*,b.kkbmdm from (select xn,xq,xkkh,xh,xm,kcmc,qzxs,xf,cj,zscj,bz,xgsj,xgs,cxbj,tzf,tzfjd,kcdm,pscj,qmcj,sycj,bkcj,cxcj,kcxz,tj,tjbz,cxxnxq,qzcj,kcgs,fxbj,jf,xsqr,sfkc,ysbkcj,McjN,McxcjN,zpZ,bkcjZ,cxcjZ,cxcj1Z,cxcj2Z,cxcj3Z,cxcj4Z,cxcj5Z,cxcj1,cxcj2,cxcj3,cxcj4,cxcj5,McjX,McxcjX,McjzPN,jycj,MjyN,MjycjN,MjybkcjN,MjycxcjN,MjycxbkcjN ,(case when (select x.kcdm from wjdszb x where x.kcdm=substr(a.xkkh,case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1,case when instr(a.xkkh,'-',1,4)<>0 then instr(a.xkkh,'-',1,4) else length(a.xkkh)+1 end-(case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1))) is null then (case when ((select x.mc from cjlrbzb x where (','||a.bz||',' like '%,'||x.mc||',%' or ','||a.cj||',' like '%,'||x.mc||',%') and x.sfwjd='是') is null) then to_char( ( (case when McxcjN>=60 then ( select max(to_number(jd)) from (select substr(cj,1,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end-(1)) as qsd,substr(cj,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1,case when instr(cj,'-',1,2)<>0 then instr(cj,'-',1,2) else length(cj)+1 end-(case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1)) as jsd,jd from bkcxjddzb where lb='重修' and cj like '%-%') a where to_number(qsd)<=McxcjN and to_number(jsd)>McxcjN ) when bkcjZ>=60 then ( select max(to_number(jd)) from (select substr(cj,1,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end-(1)) as qsd,substr(cj,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1,case when instr(cj,'-',1,2)<>0 then instr(cj,'-',1,2) else length(cj)+1 end-(case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1)) as jsd,jd from bkcxjddzb where lb='补考' and cj like '%-%') a where to_number(qsd)<=bkcjZ and to_number(jsd)>bkcjZ ) else to_number( ( select max(to_number(jd)) from (select substr(cj,1,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end-(1)) as qsd,substr(cj,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1,case when instr(cj,'-',1,10)<>0 then instr(cj,'-',1,10) else length(cj)+1 end-(case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1)) as jsd,jd from jddzb where cj like '%-%') a where to_number(qsd)<=ZpZ and to_number(jsd)>ZpZ )) end ) *(case when (select max(to_number(nvl(z.kcqzxs,1))) from kcxzdmb Z where a.kcxz=Z.kcxzmc) is null then 1 else (select max(to_number(nvl(z.kcqzxs,1))) from kcxzdmb Z where a.kcxz=Z.kcxzmc) end) )) else '' end) else '' end) jd ,case when McxcjX is not null then '*' else '' end dcxbj,cxdtcj,case when bkcj is not null then '*' else '' end bkcjbj from ( select a.*,case when McjN=zpZ then cj when McjN=bkcjZ then bkcj||'' when (McjN=cxcjZ and cxcj is not null) then cxcj||'' when (McjN=cxcj1Z and cxcj1 is not null) then cxcj1||'' when (McjN=cxcj2Z and cxcj2 is not null) then cxcj2||'' when (McjN=cxcj3Z and cxcj3 is not null) then cxcj3||'' when (McjN=cxcj4Z and cxcj4 is not null) then cxcj4||'' when (McjN=cxcj5Z and cxcj5 is not null) then cxcj5||'' end McjX, case when (McjN=cxcjZ and cxcj is not null) then cxcj||'' when (McjN=cxcj1Z and cxcj1 is not null) then cxcj1||'' when (McjN=cxcj2Z and cxcj2 is not null) then cxcj2||'' when (McjN=cxcj3Z and cxcj3 is not null) then cxcj3||'' when (McjN=cxcj4Z and cxcj4 is not null) then cxcj4||'' when (McjN=cxcj5Z and cxcj5 is not null) then cxcj5||'' end McxcjX from (select a.*, case when pscjN is null then 0 else to_number(pscjN) end pscjZ, case when qmcjN is null then 0 else to_number(qmcjN) end qmcjZ, case when sycjN is null then 0 else to_number(sycjN) end sycjZ, case when zpN is null then 0 else to_number(zpN) end zpZ, case when bkcjN is null then 0 else to_number(bkcjN) end bkcjZ, case when cxcjN is null then 0 else to_number(cxcjN) end cxcjZ, case when cxcj1N is null then 0 else to_number(cxcj1N) end cxcj1Z, case when cxcj2N is null then 0 else to_number(cxcj2N) end cxcj2Z, case when cxcj3N is null then 0 else to_number(cxcj3N) end cxcj3Z, case when cxcj4N is null then 0 else to_number(cxcj4N) end cxcj4Z, case when cxcj5N is null then 0 else to_number(cxcj5N) end cxcj5Z, case when bybkcjN is null then 0 else to_number(bybkcjN) end bybkcjZ, greatest(case when zpN is null then 0 else to_number(zpN) end,case when bkcjN is null then 0 else to_number(bkcjN) end,case when cxcjN is null then 0 else to_number(cxcjN) end, case when cxcj1N is null then 0 else to_number(cxcj1N) end,case when cxcj2N is null then 0 else to_number(cxcj2N) end,case when cxcj3N is null then 0 else to_number(cxcj3N) end ,case when cxcj4N is null then 0 else to_number(cxcj4N) end,case when cxcj5N is null then 0 else to_number(cxcj5N) end ) McjN, least(case when zpN is null then 0 else to_number(zpN) end,case when bkcjN is null then 0 else to_number(bkcjN) end,case when cxcjN is null then 0 else to_number(cxcjN) end, case when cxcj1N is null then 0 else to_number(cxcj1N) end,case when cxcj2N is null then 0 else to_number(cxcj2N) end,case when cxcj3N is null then 0 else to_number(cxcj3N) end ,case when cxcj4N is null then 0 else to_number(cxcj4N) end,case when cxcj5N is null then 0 else to_number(cxcj5N) end ) MincjN, greatest(to_number('0'||bkcjN),to_number('0'||zpN) ) McjzPN, greatest(case when cxcjN is null then 0 else to_number(cxcjN) end, case when cxcj1N is null then 0 else to_number(cxcj1N) end,case when cxcj2N is null then 0 else to_number(cxcj2N) end,case when cxcj3N is null then 0 else to_number(cxcj3N) end ,case when cxcj4N is null then 0 else to_number(cxcj4N) end,case when cxcj5N is null then 0 else to_number(cxcj5N) end ) McxcjN ,least(nvl(upper(jycj),'W'),nvl(upper(MjycxcjN),'W')) MjycjN ,least(nvl(upper(jybkcj),'W'),nvl(upper(MjycxbkcjN),'W')) MjybkcjN ,least(nvl(upper(jycj),'W'),nvl(upper(MjycxcjN),'W'),nvl(upper(jybkcj),'W'),nvl(upper(MjycxbkcjN),'W')) MjyN from (select cjb.*, case when (select dycj from cjdzb where cj=cjb.pscj) is null then cjb.pscj else (select to_char(dycj) from cjdzb where cj=cjb.pscj) end pscjN, case when (select dycj from cjdzb where cj=cjb.qmcj) is null then cjb.qmcj else (select to_char(dycj) from cjdzb where cj=cjb.qmcj) end qmcjN, case when (select dycj from cjdzb where cj=cjb.sycj) is null then cjb.sycj else (select to_char(dycj) from cjdzb where cj=cjb.sycj) end sycjN, case when (select dycj from cjdzb where cj=cjb.cj) is null then cjb.cj else (select to_char(dycj) from cjdzb where cj=cjb.cj) end zpN, case when (select dycj from cjdzb where cj=cjb.bkcj) is null then cjb.bkcj else (select to_char(dycj) from cjdzb where cj=cjb.bkcj) end bkcjN, case when (select dycj from cjdzb where cj=cjb.cxcj) is null then cjb.cxcj else (select to_char(dycj) from cjdzb where cj=cjb.cxcj) end cxcjN, case when (select dycj from cjdzb where cj=cjb.cxcj1) is null then cjb.cxcj1 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj1) end cxcj1N, case when (select dycj from cjdzb where cj=cjb.cxcj2) is null then cjb.cxcj2 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj2) end cxcj2N , case when (select dycj from cjdzb where cj=cjb.cxcj3) is null then cjb.cxcj3 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj3) end cxcj3N, case when (select dycj from cjdzb where cj=cjb.cxcj4) is null then cjb.cxcj4 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj4) end cxcj4N, case when (select dycj from cjdzb where cj=cjb.cxcj5) is null then cjb.cxcj5 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj5) end cxcj5N, case when (select dycj from cjdzb where cj=cjb.bybkcj) is null then cjb.bybkcj else (select to_char(dycj) from cjdzb where cj=cjb.bybkcj) end bybkcjN from (select xn,xq,xkkh,xh,xm,kcmc,qzxs,xf,cj,zscj,bz,xgsj,xgs,cxbj,tzf,tzfjd,kcdm,pscj,qmcj,sycj,bkcj,cxcj,kcxz,tj,tjbz,cxxnxq,qzcj,kcgs,fxbj,jf,xsqr,jd,cxcj1,cxcj2,cxcj3,cxcj4,cxcj5,cxdtcj,jycj,jybkcj,MjycxcjN,MjycxbkcjN,bybkcj,sfkc,ysbkcj from cjb_3) cjb ) a) a ) a ) a,kcdmb b where a.xh='0407100522' and (sfkc is null or sfkc<>'否') and substr(a.xkkh,case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1,case when instr(a.xkkh,'-',1,4)<>0 then instr(a.xkkh,'-',1,4) else length(a.xkkh)+1 end-(case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1))=b.kcdm(+) order by a.xkkh) a,xydmb b where a.kkbmdm=b.xydm(+) order by xn,xq,kcxz)) group by kcxz) b on a.kcxzmc=b.kcxz union all select '99','合计',sum(xfyq),sum(xfh1),sum(xfh2),sum(xfc) from (select case when a.kcxzdm is null then '98' else a.kcxzdm end kcxzdm,a.kcxzmc,case when a.xfyq is null then 0 else to_number(a.xfyq) end xfyq ,b.xfh1,b.xfh2,to_number(to_number((case when a.xfyq is null then 0 else to_number(a.xfyq) end))-to_number(b.xfh1)) xfc from (select * from jxjhxfyqview where jxjhh=(select dqszj||zydm from xsjbxxb where xh='0407100522')) a left join (select kcxz,case when sum(xf1) is null then 0 else sum(xf1) end xfh1,case when sum(xf2) is null then 0 else sum(xf2) end xfh2 from (select kcdm,kcmc,kcxz,cj,xf,decode(floor(McjN/60),1,xf) xf1,decode(floor(McjN/60),0,xf) xf2 from (select a.*,b.xymc from (select a.*,b.kkbmdm from (select xn,xq,xkkh,xh,xm,kcmc,qzxs,xf,cj,zscj,bz,xgsj,xgs,cxbj,tzf,tzfjd,kcdm,pscj,qmcj,sycj,bkcj,cxcj,kcxz,tj,tjbz,cxxnxq,qzcj,kcgs,fxbj,jf,xsqr,sfkc,ysbkcj,McjN,McxcjN,zpZ,bkcjZ,cxcjZ,cxcj1Z,cxcj2Z,cxcj3Z,cxcj4Z,cxcj5Z,cxcj1,cxcj2,cxcj3,cxcj4,cxcj5,McjX,McxcjX,McjzPN,jycj,MjyN,MjycjN,MjybkcjN,MjycxcjN,MjycxbkcjN ,(case when (select x.kcdm from wjdszb x where x.kcdm=substr(a.xkkh,case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1,case when instr(a.xkkh,'-',1,4)<>0 then instr(a.xkkh,'-',1,4) else length(a.xkkh)+1 end-(case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1))) is null then (case when ((select x.mc from cjlrbzb x where (','||a.bz||',' like '%,'||x.mc||',%' or ','||a.cj||',' like '%,'||x.mc||',%') and x.sfwjd='是') is null) then to_char( ( (case when McxcjN>=60 then ( select max(to_number(jd)) from (select substr(cj,1,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end-(1)) as qsd,substr(cj,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1,case when instr(cj,'-',1,2)<>0 then instr(cj,'-',1,2) else length(cj)+1 end-(case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1)) as jsd,jd from bkcxjddzb where lb='重修' and cj like '%-%') a where to_number(qsd)<=McxcjN and to_number(jsd)>McxcjN ) when bkcjZ>=60 then ( select max(to_number(jd)) from (select substr(cj,1,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end-(1)) as qsd,substr(cj,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1,case when instr(cj,'-',1,2)<>0 then instr(cj,'-',1,2) else length(cj)+1 end-(case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1)) as jsd,jd from bkcxjddzb where lb='补考' and cj like '%-%') a where to_number(qsd)<=bkcjZ and to_number(jsd)>bkcjZ ) else to_number( ( select max(to_number(jd)) from (select substr(cj,1,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end-(1)) as qsd,substr(cj,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1,case when instr(cj,'-',1,10)<>0 then instr(cj,'-',1,10) else length(cj)+1 end-(case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1)) as jsd,jd from jddzb where cj like '%-%') a where to_number(qsd)<=ZpZ and to_number(jsd)>ZpZ )) end ) *(case when (select max(to_number(nvl(z.kcqzxs,1))) from kcxzdmb Z where a.kcxz=Z.kcxzmc) is null then 1 else (select max(to_number(nvl(z.kcqzxs,1))) from kcxzdmb Z where a.kcxz=Z.kcxzmc) end) )) else '' end) else '' end) jd ,case when McxcjX is not null then '*' else '' end dcxbj,cxdtcj,case when bkcj is not null then '*' else '' end bkcjbj from ( select a.*,case when McjN=zpZ then cj when McjN=bkcjZ then bkcj||'' when (McjN=cxcjZ and cxcj is not null) then cxcj||'' when (McjN=cxcj1Z and cxcj1 is not null) then cxcj1||'' when (McjN=cxcj2Z and cxcj2 is not null) then cxcj2||'' when (McjN=cxcj3Z and cxcj3 is not null) then cxcj3||'' when (McjN=cxcj4Z and cxcj4 is not null) then cxcj4||'' when (McjN=cxcj5Z and cxcj5 is not null) then cxcj5||'' end McjX, case when (McjN=cxcjZ and cxcj is not null) then cxcj||'' when (McjN=cxcj1Z and cxcj1 is not null) then cxcj1||'' when (McjN=cxcj2Z and cxcj2 is not null) then cxcj2||'' when (McjN=cxcj3Z and cxcj3 is not null) then cxcj3||'' when (McjN=cxcj4Z and cxcj4 is not null) then cxcj4||'' when (McjN=cxcj5Z and cxcj5 is not null) then cxcj5||'' end McxcjX from (select a.*, case when pscjN is null then 0 else to_number(pscjN) end pscjZ, case when qmcjN is null then 0 else to_number(qmcjN) end qmcjZ, case when sycjN is null then 0 else to_number(sycjN) end sycjZ, case when zpN is null then 0 else to_number(zpN) end zpZ, case when bkcjN is null then 0 else to_number(bkcjN) end bkcjZ, case when cxcjN is null then 0 else to_number(cxcjN) end cxcjZ, case when cxcj1N is null then 0 else to_number(cxcj1N) end cxcj1Z, case when cxcj2N is null then 0 else to_number(cxcj2N) end cxcj2Z, case when cxcj3N is null then 0 else to_number(cxcj3N) end cxcj3Z, case when cxcj4N is null then 0 else to_number(cxcj4N) end cxcj4Z, case when cxcj5N is null then 0 else to_number(cxcj5N) end cxcj5Z, case when bybkcjN is null then 0 else to_number(bybkcjN) end bybkcjZ, greatest(case when zpN is null then 0 else to_number(zpN) end,case when bkcjN is null then 0 else to_number(bkcjN) end,case when cxcjN is null then 0 else to_number(cxcjN) end, case when cxcj1N is null then 0 else to_number(cxcj1N) end,case when cxcj2N is null then 0 else to_number(cxcj2N) end,case when cxcj3N is null then 0 else to_number(cxcj3N) end ,case when cxcj4N is null then 0 else to_number(cxcj4N) end,case when cxcj5N is null then 0 else to_number(cxcj5N) end ) McjN, least(case when zpN is null then 0 else to_number(zpN) end,case when bkcjN is null then 0 else to_number(bkcjN) end,case when cxcjN is null then 0 else to_number(cxcjN) end, case when cxcj1N is null then 0 else to_number(cxcj1N) end,case when cxcj2N is null then 0 else to_number(cxcj2N) end,case when cxcj3N is null then 0 else to_number(cxcj3N) end ,case when cxcj4N is null then 0 else to_number(cxcj4N) end,case when cxcj5N is null then 0 else to_number(cxcj5N) end ) MincjN, greatest(to_number('0'||bkcjN),to_number('0'||zpN) ) McjzPN, greatest(case when cxcjN is null then 0 else to_number(cxcjN) end, case when cxcj1N is null then 0 else to_number(cxcj1N) end,case when cxcj2N is null then 0 else to_number(cxcj2N) end,case when cxcj3N is null then 0 else to_number(cxcj3N) end ,case when cxcj4N is null then 0 else to_number(cxcj4N) end,case when cxcj5N is null then 0 else to_number(cxcj5N) end ) McxcjN ,least(nvl(upper(jycj),'W'),nvl(upper(MjycxcjN),'W')) MjycjN ,least(nvl(upper(jybkcj),'W'),nvl(upper(MjycxbkcjN),'W')) MjybkcjN ,least(nvl(upper(jycj),'W'),nvl(upper(MjycxcjN),'W'),nvl(upper(jybkcj),'W'),nvl(upper(MjycxbkcjN),'W')) MjyN from (select cjb.*, case when (select dycj from cjdzb where cj=cjb.pscj) is null then cjb.pscj else (select to_char(dycj) from cjdzb where cj=cjb.pscj) end pscjN, case when (select dycj from cjdzb where cj=cjb.qmcj) is null then cjb.qmcj else (select to_char(dycj) from cjdzb where cj=cjb.qmcj) end qmcjN, case when (select dycj from cjdzb where cj=cjb.sycj) is null then cjb.sycj else (select to_char(dycj) from cjdzb where cj=cjb.sycj) end sycjN, case when (select dycj from cjdzb where cj=cjb.cj) is null then cjb.cj else (select to_char(dycj) from cjdzb where cj=cjb.cj) end zpN, case when (select dycj from cjdzb where cj=cjb.bkcj) is null then cjb.bkcj else (select to_char(dycj) from cjdzb where cj=cjb.bkcj) end bkcjN, case when (select dycj from cjdzb where cj=cjb.cxcj) is null then cjb.cxcj else (select to_char(dycj) from cjdzb where cj=cjb.cxcj) end cxcjN, case when (select dycj from cjdzb where cj=cjb.cxcj1) is null then cjb.cxcj1 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj1) end cxcj1N, case when (select dycj from cjdzb where cj=cjb.cxcj2) is null then cjb.cxcj2 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj2) end cxcj2N , case when (select dycj from cjdzb where cj=cjb.cxcj3) is null then cjb.cxcj3 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj3) end cxcj3N, case when (select dycj from cjdzb where cj=cjb.cxcj4) is null then cjb.cxcj4 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj4) end cxcj4N, case when (select dycj from cjdzb where cj=cjb.cxcj5) is null then cjb.cxcj5 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj5) end cxcj5N, case when (select dycj from cjdzb where cj=cjb.bybkcj) is null then cjb.bybkcj else (select to_char(dycj) from cjdzb where cj=cjb.bybkcj) end bybkcjN from (select xn,xq,xkkh,xh,xm,kcmc,qzxs,xf,cj,zscj,bz,xgsj,xgs,cxbj,tzf,tzfjd,kcdm,pscj,qmcj,sycj,bkcj,cxcj,kcxz,tj,tjbz,cxxnxq,qzcj,kcgs,fxbj,jf,xsqr,jd,cxcj1,cxcj2,cxcj3,cxcj4,cxcj5,cxdtcj,jycj,jybkcj,MjycxcjN,MjycxbkcjN,bybkcj,sfkc,ysbkcj from cjb_3) cjb ) a) a ) a ) a,kcdmb b where a.xh='0407100522' and (sfkc is null or sfkc<>'否') and substr(a.xkkh,case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1,case when instr(a.xkkh,'-',1,4)<>0 then instr(a.xkkh,'-',1,4) else length(a.xkkh)+1 end-(case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1))=b.kcdm(+) order by a.xkkh) a,xydmb b where a.kkbmdm=b.xydm(+) order by xn,xq,kcxz)) group by kcxz) b on a.kcxzmc=b.kcxz)) order by kcxzdmselect * from (select case when a.bh is null then '98' else a.bh end bh,a.xkmc,case when a.xfyq is null then 0 else to_number(a.xfyq) end xfyq ,b.xfh1,b.xfh2,to_number(to_number((case when a.xfyq is null then 0 else to_number(a.xfyq) end))-to_number(b.xfh1)) xfc from (select * from ( select a.jxjhh,a.zydm,a.zymc,a.nj,a.bh,a.xkmc, case a.bh when '1' then a.gxxfyq1 when '2' then a.gxxfyq2 when '3' then a.gxxfyq3 when '4' then a.gxxfyq4 when '5' then a.gxxfyq5 when '6' then a.gxxfyq6 when '7' then a.gxxfyq7 when '8' then a.gxxfyq8 when '9' then a.gxxfyq9 end xfyq from ( select a.jxjhh,a.zydm,a.zymc,a.nj,b.bh,b.xkmc,a.gxxfyq1,a.gxxfyq2,a.gxxfyq3,a.gxxfyq4,a.gxxfyq5,a.gxxfyq6, a.gxxfyq7,a.gxxfyq8,a.gxxfyq9,a.gxxfyq10,a.gxxfyq11,a.gxxfyq12,a.gxxfyq13,a.gxxfyq14,a.gxxfyq15, a.gxxfyq16, a.gxxfyq17, a.gxxfyq18, a.gxxfyq19, a.gxxfyq20, a.gxxfyq21, a.gxxfyq22, a.gxxfyq23, a.gxxfyq24,a.gxxfyq25,a.gxxfyq26 from jxjhzyxxb a,xkdmb b order by a.jxjhh,b.bh ) a ) where jxjhh=(select dqszj||zydm from xsjbxxb where xh='0407100522')) a left join (select kcgs,case when sum(xf1) is null then 0 else sum(xf1) end xfh1,case when sum(xf2) is null then 0 else sum(xf2) end xfh2 from (select kcdm,kcmc,kcgs,cj,xf,decode(floor(McjN/60),1,xf) xf1,decode(floor(McjN/60),0,xf) xf2 from (select a.*,b.xymc from (select a.*,b.kkbmdm from (select xn,xq,xkkh,xh,xm,kcmc,qzxs,xf,cj,zscj,bz,xgsj,xgs,cxbj,tzf,tzfjd,kcdm,pscj,qmcj,sycj,bkcj,cxcj,kcxz,tj,tjbz,cxxnxq,qzcj,kcgs,fxbj,jf,xsqr,sfkc,ysbkcj,McjN,McxcjN,zpZ,bkcjZ,cxcjZ,cxcj1Z,cxcj2Z,cxcj3Z,cxcj4Z,cxcj5Z,cxcj1,cxcj2,cxcj3,cxcj4,cxcj5,McjX,McxcjX,McjzPN,jycj,MjyN,MjycjN,MjybkcjN,MjycxcjN,MjycxbkcjN ,(case when (select x.kcdm from wjdszb x where x.kcdm=substr(a.xkkh,case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1,case when instr(a.xkkh,'-',1,4)<>0 then instr(a.xkkh,'-',1,4) else length(a.xkkh)+1 end-(case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1))) is null then (case when ((select x.mc from cjlrbzb x where (','||a.bz||',' like '%,'||x.mc||',%' or ','||a.cj||',' like '%,'||x.mc||',%') and x.sfwjd='是') is null) then to_char( ( (case when McxcjN>=60 then ( select max(to_number(jd)) from (select substr(cj,1,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end-(1)) as qsd,substr(cj,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1,case when instr(cj,'-',1,2)<>0 then instr(cj,'-',1,2) else length(cj)+1 end-(case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1)) as jsd,jd from bkcxjddzb where lb='重修' and cj like '%-%') a where to_number(qsd)<=McxcjN and to_number(jsd)>McxcjN ) when bkcjZ>=60 then ( select max(to_number(jd)) from (select substr(cj,1,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end-(1)) as qsd,substr(cj,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1,case when instr(cj,'-',1,2)<>0 then instr(cj,'-',1,2) else length(cj)+1 end-(case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1)) as jsd,jd from bkcxjddzb where lb='补考' and cj like '%-%') a where to_number(qsd)<=bkcjZ and to_number(jsd)>bkcjZ ) else to_number( ( select max(to_number(jd)) from (select substr(cj,1,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end-(1)) as qsd,substr(cj,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1,case when instr(cj,'-',1,10)<>0 then instr(cj,'-',1,10) else length(cj)+1 end-(case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1)) as jsd,jd from jddzb where cj like '%-%') a where to_number(qsd)<=ZpZ and to_number(jsd)>ZpZ )) end ) *(case when (select max(to_number(nvl(z.kcqzxs,1))) from kcxzdmb Z where a.kcxz=Z.kcxzmc) is null then 1 else (select max(to_number(nvl(z.kcqzxs,1))) from kcxzdmb Z where a.kcxz=Z.kcxzmc) end) )) else '' end) else '' end) jd ,case when McxcjX is not null then '*' else '' end dcxbj,cxdtcj,case when bkcj is not null then '*' else '' end bkcjbj from ( select a.*,case when McjN=zpZ then cj when McjN=bkcjZ then bkcj||'' when (McjN=cxcjZ and cxcj is not null) then cxcj||'' when (McjN=cxcj1Z and cxcj1 is not null) then cxcj1||'' when (McjN=cxcj2Z and cxcj2 is not null) then cxcj2||'' when (McjN=cxcj3Z and cxcj3 is not null) then cxcj3||'' when (McjN=cxcj4Z and cxcj4 is not null) then cxcj4||'' when (McjN=cxcj5Z and cxcj5 is not null) then cxcj5||'' end McjX, case when (McjN=cxcjZ and cxcj is not null) then cxcj||'' when (McjN=cxcj1Z and cxcj1 is not null) then cxcj1||'' when (McjN=cxcj2Z and cxcj2 is not null) then cxcj2||'' when (McjN=cxcj3Z and cxcj3 is not null) then cxcj3||'' when (McjN=cxcj4Z and cxcj4 is not null) then cxcj4||'' when (McjN=cxcj5Z and cxcj5 is not null) then cxcj5||'' end McxcjX from (select a.*, case when pscjN is null then 0 else to_number(pscjN) end pscjZ, case when qmcjN is null then 0 else to_number(qmcjN) end qmcjZ, case when sycjN is null then 0 else to_number(sycjN) end sycjZ, case when zpN is null then 0 else to_number(zpN) end zpZ, case when bkcjN is null then 0 else to_number(bkcjN) end bkcjZ, case when cxcjN is null then 0 else to_number(cxcjN) end cxcjZ, case when cxcj1N is null then 0 else to_number(cxcj1N) end cxcj1Z, case when cxcj2N is null then 0 else to_number(cxcj2N) end cxcj2Z, case when cxcj3N is null then 0 else to_number(cxcj3N) end cxcj3Z, case when cxcj4N is null then 0 else to_number(cxcj4N) end cxcj4Z, case when cxcj5N is null then 0 else to_number(cxcj5N) end cxcj5Z, case when bybkcjN is null then 0 else to_number(bybkcjN) end bybkcjZ, greatest(case when zpN is null then 0 else to_number(zpN) end,case when bkcjN is null then 0 else to_number(bkcjN) end,case when cxcjN is null then 0 else to_number(cxcjN) end, case when cxcj1N is null then 0 else to_number(cxcj1N) end,case when cxcj2N is null then 0 else to_number(cxcj2N) end,case when cxcj3N is null then 0 else to_number(cxcj3N) end ,case when cxcj4N is null then 0 else to_number(cxcj4N) end,case when cxcj5N is null then 0 else to_number(cxcj5N) end ) McjN, least(case when zpN is null then 0 else to_number(zpN) end,case when bkcjN is null then 0 else to_number(bkcjN) end,case when cxcjN is null then 0 else to_number(cxcjN) end, case when cxcj1N is null then 0 else to_number(cxcj1N) end,case when cxcj2N is null then 0 else to_number(cxcj2N) end,case when cxcj3N is null then 0 else to_number(cxcj3N) end ,case when cxcj4N is null then 0 else to_number(cxcj4N) end,case when cxcj5N is null then 0 else to_number(cxcj5N) end ) MincjN, greatest(to_number('0'||bkcjN),to_number('0'||zpN) ) McjzPN, greatest(case when cxcjN is null then 0 else to_number(cxcjN) end, case when cxcj1N is null then 0 else to_number(cxcj1N) end,case when cxcj2N is null then 0 else to_number(cxcj2N) end,case when cxcj3N is null then 0 else to_number(cxcj3N) end ,case when cxcj4N is null then 0 else to_number(cxcj4N) end,case when cxcj5N is null then 0 else to_number(cxcj5N) end ) McxcjN ,least(nvl(upper(jycj),'W'),nvl(upper(MjycxcjN),'W')) MjycjN ,least(nvl(upper(jybkcj),'W'),nvl(upper(MjycxbkcjN),'W')) MjybkcjN ,least(nvl(upper(jycj),'W'),nvl(upper(MjycxcjN),'W'),nvl(upper(jybkcj),'W'),nvl(upper(MjycxbkcjN),'W')) MjyN from (select cjb.*, case when (select dycj from cjdzb where cj=cjb.pscj) is null then cjb.pscj else (select to_char(dycj) from cjdzb where cj=cjb.pscj) end pscjN, case when (select dycj from cjdzb where cj=cjb.qmcj) is null then cjb.qmcj else (select to_char(dycj) from cjdzb where cj=cjb.qmcj) end qmcjN, case when (select dycj from cjdzb where cj=cjb.sycj) is null then cjb.sycj else (select to_char(dycj) from cjdzb where cj=cjb.sycj) end sycjN, case when (select dycj from cjdzb where cj=cjb.cj) is null then cjb.cj else (select to_char(dycj) from cjdzb where cj=cjb.cj) end zpN, case when (select dycj from cjdzb where cj=cjb.bkcj) is null then cjb.bkcj else (select to_char(dycj) from cjdzb where cj=cjb.bkcj) end bkcjN, case when (select dycj from cjdzb where cj=cjb.cxcj) is null then cjb.cxcj else (select to_char(dycj) from cjdzb where cj=cjb.cxcj) end cxcjN, case when (select dycj from cjdzb where cj=cjb.cxcj1) is null then cjb.cxcj1 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj1) end cxcj1N, case when (select dycj from cjdzb where cj=cjb.cxcj2) is null then cjb.cxcj2 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj2) end cxcj2N , case when (select dycj from cjdzb where cj=cjb.cxcj3) is null then cjb.cxcj3 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj3) end cxcj3N, case when (select dycj from cjdzb where cj=cjb.cxcj4) is null then cjb.cxcj4 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj4) end cxcj4N, case when (select dycj from cjdzb where cj=cjb.cxcj5) is null then cjb.cxcj5 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj5) end cxcj5N, case when (select dycj from cjdzb where cj=cjb.bybkcj) is null then cjb.bybkcj else (select to_char(dycj) from cjdzb where cj=cjb.bybkcj) end bybkcjN from (select xn,xq,xkkh,xh,xm,kcmc,qzxs,xf,cj,zscj,bz,xgsj,xgs,cxbj,tzf,tzfjd,kcdm,pscj,qmcj,sycj,bkcj,cxcj,kcxz,tj,tjbz,cxxnxq,qzcj,kcgs,fxbj,jf,xsqr,jd,cxcj1,cxcj2,cxcj3,cxcj4,cxcj5,cxdtcj,jycj,jybkcj,MjycxcjN,MjycxbkcjN,bybkcj,sfkc,ysbkcj from cjb_3) cjb ) a) a ) a ) a,kcdmb b where a.xh='0407100522' and (sfkc is null or sfkc<>'否') and substr(a.xkkh,case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1,case when instr(a.xkkh,'-',1,4)<>0 then instr(a.xkkh,'-',1,4) else length(a.xkkh)+1 end-(case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1))=b.kcdm(+) order by a.xkkh) a,xydmb b where a.kkbmdm=b.xydm(+) order by xn,xq,kcxz)) group by kcgs) b on a.xkmc=b.kcgs union all select 'Z99','合计',sum(xfyq),sum(xfh1),sum(xfh2),sum(xfc) from (select case when a.bh is null then '98' else a.bh end bh,a.xkmc,case when a.xfyq is null then 0 else to_number(a.xfyq) end xfyq ,b.xfh1,b.xfh2,to_number(to_number((case when a.xfyq is null then 0 else to_number(a.xfyq) end))-to_number(b.xfh1)) xfc from (select * from ( select a.jxjhh,a.zydm,a.zymc,a.nj,a.bh,a.xkmc, case a.bh when '1' then a.gxxfyq1 when '2' then a.gxxfyq2 when '3' then a.gxxfyq3 when '4' then a.gxxfyq4 when '5' then a.gxxfyq5 when '6' then a.gxxfyq6 when '7' then a.gxxfyq7 when '8' then a.gxxfyq8 when '9' then a.gxxfyq9 end xfyq from ( select a.jxjhh,a.zydm,a.zymc,a.nj,b.bh,b.xkmc,a.gxxfyq1,a.gxxfyq2,a.gxxfyq3,a.gxxfyq4,a.gxxfyq5,a.gxxfyq6, a.gxxfyq7,a.gxxfyq8,a.gxxfyq9,a.gxxfyq10,a.gxxfyq11,a.gxxfyq12,a.gxxfyq13,a.gxxfyq14,a.gxxfyq15, a.gxxfyq16, a.gxxfyq17, a.gxxfyq18, a.gxxfyq19, a.gxxfyq20, a.gxxfyq21, a.gxxfyq22, a.gxxfyq23, a.gxxfyq24,a.gxxfyq25,a.gxxfyq26 from jxjhzyxxb a,xkdmb b order by a.jxjhh,b.bh ) a ) where jxjhh=(select dqszj||zydm from xsjbxxb where xh='0407100522')) a left join (select kcgs,case when sum(xf1) is null then 0 else sum(xf1) end xfh1,case when sum(xf2) is null then 0 else sum(xf2) end xfh2 from (select kcdm,kcmc,kcgs,cj,xf,decode(floor(McjN/60),1,xf) xf1,decode(floor(McjN/60),0,xf) xf2 from (select a.*,b.xymc from (select a.*,b.kkbmdm from (select xn,xq,xkkh,xh,xm,kcmc,qzxs,xf,cj,zscj,bz,xgsj,xgs,cxbj,tzf,tzfjd,kcdm,pscj,qmcj,sycj,bkcj,cxcj,kcxz,tj,tjbz,cxxnxq,qzcj,kcgs,fxbj,jf,xsqr,sfkc,ysbkcj,McjN,McxcjN,zpZ,bkcjZ,cxcjZ,cxcj1Z,cxcj2Z,cxcj3Z,cxcj4Z,cxcj5Z,cxcj1,cxcj2,cxcj3,cxcj4,cxcj5,McjX,McxcjX,McjzPN,jycj,MjyN,MjycjN,MjybkcjN,MjycxcjN,MjycxbkcjN ,(case when (select x.kcdm from wjdszb x where x.kcdm=substr(a.xkkh,case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1,case when instr(a.xkkh,'-',1,4)<>0 then instr(a.xkkh,'-',1,4) else length(a.xkkh)+1 end-(case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1))) is null then (case when ((select x.mc from cjlrbzb x where (','||a.bz||',' like '%,'||x.mc||',%' or ','||a.cj||',' like '%,'||x.mc||',%') and x.sfwjd='是') is null) then to_char( ( (case when McxcjN>=60 then ( select max(to_number(jd)) from (select substr(cj,1,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end-(1)) as qsd,substr(cj,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1,case when instr(cj,'-',1,2)<>0 then instr(cj,'-',1,2) else length(cj)+1 end-(case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1)) as jsd,jd from bkcxjddzb where lb='重修' and cj like '%-%') a where to_number(qsd)<=McxcjN and to_number(jsd)>McxcjN ) when bkcjZ>=60 then ( select max(to_number(jd)) from (select substr(cj,1,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end-(1)) as qsd,substr(cj,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1,case when instr(cj,'-',1,2)<>0 then instr(cj,'-',1,2) else length(cj)+1 end-(case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1)) as jsd,jd from bkcxjddzb where lb='补考' and cj like '%-%') a where to_number(qsd)<=bkcjZ and to_number(jsd)>bkcjZ ) else to_number( ( select max(to_number(jd)) from (select substr(cj,1,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end-(1)) as qsd,substr(cj,case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1,case when instr(cj,'-',1,10)<>0 then instr(cj,'-',1,10) else length(cj)+1 end-(case when instr(cj,'-',1,1)<>0 then instr(cj,'-',1,1) else length(cj)+1 end+1)) as jsd,jd from jddzb where cj like '%-%') a where to_number(qsd)<=ZpZ and to_number(jsd)>ZpZ )) end ) *(case when (select max(to_number(nvl(z.kcqzxs,1))) from kcxzdmb Z where a.kcxz=Z.kcxzmc) is null then 1 else (select max(to_number(nvl(z.kcqzxs,1))) from kcxzdmb Z where a.kcxz=Z.kcxzmc) end) )) else '' end) else '' end) jd ,case when McxcjX is not null then '*' else '' end dcxbj,cxdtcj,case when bkcj is not null then '*' else '' end bkcjbj from ( select a.*,case when McjN=zpZ then cj when McjN=bkcjZ then bkcj||'' when (McjN=cxcjZ and cxcj is not null) then cxcj||'' when (McjN=cxcj1Z and cxcj1 is not null) then cxcj1||'' when (McjN=cxcj2Z and cxcj2 is not null) then cxcj2||'' when (McjN=cxcj3Z and cxcj3 is not null) then cxcj3||'' when (McjN=cxcj4Z and cxcj4 is not null) then cxcj4||'' when (McjN=cxcj5Z and cxcj5 is not null) then cxcj5||'' end McjX, case when (McjN=cxcjZ and cxcj is not null) then cxcj||'' when (McjN=cxcj1Z and cxcj1 is not null) then cxcj1||'' when (McjN=cxcj2Z and cxcj2 is not null) then cxcj2||'' when (McjN=cxcj3Z and cxcj3 is not null) then cxcj3||'' when (McjN=cxcj4Z and cxcj4 is not null) then cxcj4||'' when (McjN=cxcj5Z and cxcj5 is not null) then cxcj5||'' end McxcjX from (select a.*, case when pscjN is null then 0 else to_number(pscjN) end pscjZ, case when qmcjN is null then 0 else to_number(qmcjN) end qmcjZ, case when sycjN is null then 0 else to_number(sycjN) end sycjZ, case when zpN is null then 0 else to_number(zpN) end zpZ, case when bkcjN is null then 0 else to_number(bkcjN) end bkcjZ, case when cxcjN is null then 0 else to_number(cxcjN) end cxcjZ, case when cxcj1N is null then 0 else to_number(cxcj1N) end cxcj1Z, case when cxcj2N is null then 0 else to_number(cxcj2N) end cxcj2Z, case when cxcj3N is null then 0 else to_number(cxcj3N) end cxcj3Z, case when cxcj4N is null then 0 else to_number(cxcj4N) end cxcj4Z, case when cxcj5N is null then 0 else to_number(cxcj5N) end cxcj5Z, case when bybkcjN is null then 0 else to_number(bybkcjN) end bybkcjZ, greatest(case when zpN is null then 0 else to_number(zpN) end,case when bkcjN is null then 0 else to_number(bkcjN) end,case when cxcjN is null then 0 else to_number(cxcjN) end, case when cxcj1N is null then 0 else to_number(cxcj1N) end,case when cxcj2N is null then 0 else to_number(cxcj2N) end,case when cxcj3N is null then 0 else to_number(cxcj3N) end ,case when cxcj4N is null then 0 else to_number(cxcj4N) end,case when cxcj5N is null then 0 else to_number(cxcj5N) end ) McjN, least(case when zpN is null then 0 else to_number(zpN) end,case when bkcjN is null then 0 else to_number(bkcjN) end,case when cxcjN is null then 0 else to_number(cxcjN) end, case when cxcj1N is null then 0 else to_number(cxcj1N) end,case when cxcj2N is null then 0 else to_number(cxcj2N) end,case when cxcj3N is null then 0 else to_number(cxcj3N) end ,case when cxcj4N is null then 0 else to_number(cxcj4N) end,case when cxcj5N is null then 0 else to_number(cxcj5N) end ) MincjN, greatest(to_number('0'||bkcjN),to_number('0'||zpN) ) McjzPN, greatest(case when cxcjN is null then 0 else to_number(cxcjN) end, case when cxcj1N is null then 0 else to_number(cxcj1N) end,case when cxcj2N is null then 0 else to_number(cxcj2N) end,case when cxcj3N is null then 0 else to_number(cxcj3N) end ,case when cxcj4N is null then 0 else to_number(cxcj4N) end,case when cxcj5N is null then 0 else to_number(cxcj5N) end ) McxcjN ,least(nvl(upper(jycj),'W'),nvl(upper(MjycxcjN),'W')) MjycjN ,least(nvl(upper(jybkcj),'W'),nvl(upper(MjycxbkcjN),'W')) MjybkcjN ,least(nvl(upper(jycj),'W'),nvl(upper(MjycxcjN),'W'),nvl(upper(jybkcj),'W'),nvl(upper(MjycxbkcjN),'W')) MjyN from (select cjb.*, case when (select dycj from cjdzb where cj=cjb.pscj) is null then cjb.pscj else (select to_char(dycj) from cjdzb where cj=cjb.pscj) end pscjN, case when (select dycj from cjdzb where cj=cjb.qmcj) is null then cjb.qmcj else (select to_char(dycj) from cjdzb where cj=cjb.qmcj) end qmcjN, case when (select dycj from cjdzb where cj=cjb.sycj) is null then cjb.sycj else (select to_char(dycj) from cjdzb where cj=cjb.sycj) end sycjN, case when (select dycj from cjdzb where cj=cjb.cj) is null then cjb.cj else (select to_char(dycj) from cjdzb where cj=cjb.cj) end zpN, case when (select dycj from cjdzb where cj=cjb.bkcj) is null then cjb.bkcj else (select to_char(dycj) from cjdzb where cj=cjb.bkcj) end bkcjN, case when (select dycj from cjdzb where cj=cjb.cxcj) is null then cjb.cxcj else (select to_char(dycj) from cjdzb where cj=cjb.cxcj) end cxcjN, case when (select dycj from cjdzb where cj=cjb.cxcj1) is null then cjb.cxcj1 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj1) end cxcj1N, case when (select dycj from cjdzb where cj=cjb.cxcj2) is null then cjb.cxcj2 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj2) end cxcj2N , case when (select dycj from cjdzb where cj=cjb.cxcj3) is null then cjb.cxcj3 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj3) end cxcj3N, case when (select dycj from cjdzb where cj=cjb.cxcj4) is null then cjb.cxcj4 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj4) end cxcj4N, case when (select dycj from cjdzb where cj=cjb.cxcj5) is null then cjb.cxcj5 else (select to_char(dycj) from cjdzb where cj=cjb.cxcj5) end cxcj5N, case when (select dycj from cjdzb where cj=cjb.bybkcj) is null then cjb.bybkcj else (select to_char(dycj) from cjdzb where cj=cjb.bybkcj) end bybkcjN from (select xn,xq,xkkh,xh,xm,kcmc,qzxs,xf,cj,zscj,bz,xgsj,xgs,cxbj,tzf,tzfjd,kcdm,pscj,qmcj,sycj,bkcj,cxcj,kcxz,tj,tjbz,cxxnxq,qzcj,kcgs,fxbj,jf,xsqr,jd,cxcj1,cxcj2,cxcj3,cxcj4,cxcj5,cxdtcj,jycj,jybkcj,MjycxcjN,MjycxbkcjN,bybkcj,sfkc,ysbkcj from cjb_3) cjb ) a) a ) a ) a,kcdmb b where a.xh='0407100522' and (sfkc is null or sfkc<>'否') and substr(a.xkkh,case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1,case when instr(a.xkkh,'-',1,4)<>0 then instr(a.xkkh,'-',1,4) else length(a.xkkh)+1 end-(case when instr(a.xkkh,'-',1,3)<>0 then instr(a.xkkh,'-',1,3) else length(a.xkkh)+1 end+1))=b.kcdm(+) order by a.xkkh) a,xydmb b where a.kkbmdm=b.xydm(+) order by xn,xq,kcxz)) group by kcgs) b on a.xkmc=b.kcgs )) order by bh
@WayneY
Copy link

WayneY commented Feb 4, 2013

需要排下版,不然真没法看……

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment