异常脚本:
select row_number() over(ORDER BY SYDW,jldw,FYLY) xh,
SYDW,
jldw,
FYLY,
wm_concat(ddxdms) ddxdms,
wm_concat(ypbhs) ypbhs,
sum(SDWCSL) SDWCSL,
sum(BQJSSL) BQJSSL,
sum(BQWCSL) BQWCSL,
TO_CHAR(sum(JSSL) / sum(BQWCSL)*100,‘FM99990.00’) jsbfl ,
TO_CHAR(sum(WCSL) / sum(YJYWCDGSL)*100,‘FM99990.00’) jsbfl
from (
select f.jldw,
SDWCSL,
a.FYLY,
b.ddxdms,
b.ypbhs,
BQJSSL,
BQWCSL,
LJWCSL,
a.SYDW,
YJYWCDGSL
from (select ddxdm, XM, yp, fy, RWDBH,SYDW, decode(count(ypbh),null,0,count(ypbh)) WCSL
from (select ddxdm, XM, ypph, fy, RWDBH, SYDW,ypbh
from Tickdetail
where fbbs =‘1’
and FYLY !=‘0’
and FBRQ between to_date(‘2019-1-1’,‘yyyy-mm-dd’) and
to_date(‘2020-5-1’,‘yyyy-mm-dd’)
group by ddxdm, XM, yp, fy, RWDBH,SYDW, ypbh)
group by ddxdm, XM, yp, fy,SYDW, RWDBH) a,
(select xm, yp, fy, RWDBH,SYDW, wm_concat(ypbh) ypbhs, wm_concat(ddxdm) ddxdms,decode(count(ypbh),null,0,count(ypbh)) BQJSSL
from (select xm, yp, fy,RWDBH,SYDW, ypbh
from Tickdetail
where fbbs = '1'
and SFJS ='1'
and FBRQ between to_date('2019-1-1','yyyy-mm-dd') and
to_date('2020-5-1','yyyy-mm-dd')
group by xm, yp, fy, RWDBH,SYDW, ypbh)
group by xm, yp, fy,SYDW, RWDBH)b,
(select xm, yp, fy,SYDW, RWDBH, decode(count(ypbh),null,0,count(ypbh)) BQWCSL
from (select xm, yp, SYDW,fy, RWDBH, ypbh
from Tickdetail
where fbbs ='1'
and FBRQ between to_date('2019-1-1','yyyy-mm-dd') and
to_date('2020-5-1','yyyy-mm-dd')
group by ddxdm, ypph,SYDW, fyly, RWDBH, ypbh)
group by ddxdm, ypph, fyly,SYDW, RWDBH) c,
Ypfxprice f
where a.ypph = b.ypph
and a.ddxdm = b.ddxdm
and a.fy = b.fy
and a.ddxdm = f.fxxmdm
and BQJSSL != '0'
and a.ypph = c.ypph
and a.ddxdm = c.ddxdm
and a.fyly = c.fyly
)
group by
FY,jldw,SYDW order by SYDW, FY,jldw
修改之后脚本:
select row_number() over(ORDER BY SYDW,jldw,FYLY) xh,
SYDW,
jldw,
FYLY,
wm_concat(ddxdms) ddxdms,
sys.stragg(to_char(ypbhs) || nvl2(ypbhs,’’, ‘’’’)) as ypbhs, --此处修改
sum(SDWCSL) SDWCSL,
sum(BQJSSL) BQJSSL,
sum(BQWCSL) BQWCSL,
TO_CHAR(sum(JSSL) / sum(BQWCSL)*100,‘FM99990.00’) jsbfl ,
TO_CHAR(sum(WCSL) / sum(YJYWCDGSL)*100,‘FM99990.00’) jsbfl
from (
select f.jldw,
SDWCSL,
a.FYLY,
b.ddxdms,
b.ypbhs,
BQJSSL,
BQWCSL,
LJWCSL,
a.SYDW,
YJYWCDGSL
from (select ddxdm, XM, yp, fy, RWDBH,SYDW, decode(count(ypbh),null,0,count(ypbh)) WCSL
from (select ddxdm, XM, ypph, fy, RWDBH, SYDW,ypbh
from Tickdetail
where fbbs =‘1’
and FYLY !=‘0’
and FBRQ between to_date(‘2019-1-1’,‘yyyy-mm-dd’) and
to_date(‘2020-5-1’,‘yyyy-mm-dd’)
group by ddxdm, XM, yp, fy, RWDBH,SYDW, ypbh)
group by ddxdm, XM, yp, fy,SYDW, RWDBH) a,
(select xm, yp, fy, RWDBH,SYDW, wm_concat(ypbh) ypbhs, wm_concat(ddxdm) ddxdms,decode(count(ypbh),null,0,count(ypbh)) BQJSSL
from (select xm, yp, fy,RWDBH,SYDW, ypbh
from Tickdetail
where fbbs = '1'
and SFJS ='1'
and FBRQ between to_date('2019-1-1','yyyy-mm-dd') and
to_date('2020-5-1','yyyy-mm-dd')
group by xm, yp, fy, RWDBH,SYDW, ypbh)
group by xm, yp, fy,SYDW, RWDBH)b,
(select xm, yp, fy,SYDW, RWDBH, decode(count(ypbh),null,0,count(ypbh)) BQWCSL
from (select xm, yp, SYDW,fy, RWDBH, ypbh
from Tickdetail
where fbbs ='1'
and FBRQ between to_date('2019-1-1','yyyy-mm-dd') and
to_date('2020-5-1','yyyy-mm-dd')
group by ddxdm, ypph,SYDW, fyly, RWDBH, ypbh)
group by ddxdm, ypph, fyly,SYDW, RWDBH) c,
Ypfxprice f
where a.ypph = b.ypph
and a.ddxdm = b.ddxdm
and a.fy = b.fy
and a.ddxdm = f.fxxmdm
and BQJSSL != '0'
and a.ypph = c.ypph
and a.ddxdm = c.ddxdm
and a.fyly = c.fyly
)
group by
FY,jldw,SYDW order by SYDW, FY,jldw