如下图所示,5月、6月均有数据,但是当时间调整到两个月的时候,数据显示不出来。弄了好久,实在不知道哪出问题了。with aa as (SELECT acct_code,cost_center,ST_NO as grade,MAT_NO,substr(mat_no,1,8) as pono,MAT_ACT_WIDTH as size,MAT_ACT_WT as weight,IN_MAT_NO,IN_MAT_WT,app_throw_ai_key,substr(apcod_date_sumnum,3,14) as ap_time,substr(close_mon,1,6) as close_monFROM "BG00MSCB00"."T_DWD_FACT_CBAI_TACAIWBLG" where cost_center in ('ABEC','ABEG') ),a as (select aa.* from aa where close_mon>='${日期起}' AND close_mon<='${日期止}' ),a1 as (select * from (select distinct pono,cost_center,grade,ap_time,row_number()over(partition by pono,cost_center order by ap_time desc ) rnfrom a where ACCT_CODE=01 order by pono,cost_center,ap_time) where rn=1),b as (select pono,cost_center,sum(weight) as LB_total from a where ACCT_CODE=01 group by pono,cost_center),c as (select pono,sum(weight) as ladle from a where ACCT_CODE='31' group by pono ),d as (select pono,-sum(weight) as sp from a where substr(app_throw_ai_key,23,2)='31' group by pono),e as (select distinct a.close_mon,a.pono,b.cost_center,b.LB_total,d.sp,c.ladle as ladle_c from a left join b on a.pono=b.pono left join c on a.pono=c.pono left join d on a.pono=d.pono where a.pono<>'' order by pono)select e.*,a1.grade,(case when e.cost_center is null then 'ABEG' else e.cost_center end) as cost_center1 from e left join a1 on e.pono=a1.pono and e.cost_center=a1.cost_center order by pono