3,490
社区成员
发帖
与我相关
我的任务
分享
select (select bmdm_name from businessAreaConcentrade where bmdm = d.companyid) companyid,
to_char(d.endorOverDate,'yyyy-mm') year_month,s.scaleofmarkdes,
count(distinct d.claimno) countnum
from (
select claimno,
substr(','||tt.CHECKSCALEOFMARK,
instr(','||tt.CHECKSCALEOFMARK,',',1,temp.rn)+1,instr(tt.CHECKSCALEOFMARK,',',1,temp.rn)
-instr(','||tt.CHECKSCALEOFMARK,',',1,temp.rn)) CHECKSCALEOFMARK,
checkdate,ENDORSCALEOFMARK,ENDORDATE
from claimScaleOfmarks tt,
(select rownum rn from dual connect by rownum<35)temp
where length(tt.CHECKSCALEOFMARK)-length(replace(tt.CHECKSCALEOFMARK,','))>=temp.rn
--order by 1,temp.rn
) c,scaleOfmarksPara s,claiminfo d
where c.claimno=d.claimno
and c.checkScaleOfmark=s.id
and (trunc(d.endorOverDate,'DD') >= to_date('2012-01-01','yyyy/mm/dd') and trunc(d.endorOverDate,'DD') <= to_date('2012-05-02','yyyy/mm/dd') )
and (c.checkScaleOfmark is not null) or (c.endorScaleOfmark is not null)
and s.score<=0
group by d.companyid,to_char(d.endorOverDate,'yyyy-mm'),s.scaleofmarkdes
order by d.companyid,to_char(d.endorOverDate,'yyyy-mm'),s.scaleofmarkdes