
    SELECT DISTINCT 'plan' type, 'detail' cate, pl.mfgdate, pl.area, pl.area1, sum(pl.outputb) / 1000 value
    from reportdata.outputtargetsetting pl
    where 1 = 1
      and pl.outputb > 0
      and pl.mfgdate >= CONCAT(dATE_FORMAT(now() - 8.5 / 24, '%Y-%m-'), '01')
      and pl.mfgdate <= DATE_FORMAT((LAST_DAY(CURDATE())), '%Y-%m-%d')
    group by pl.mfgdate, pl.area, pl.area1
    union all
##查询实际产量明细
    SELECT 'actual' type, 'detail' cate, sy.mfgdate, sy.area, sy.area1, sum(sy.qcweight) / 1000 outputb
    from siteonlinecrucibleyield sy
    where 1 = 1
      and sy.mfgdate >= CONCAT(dATE_FORMAT(now() - 8.5 / 24, '%Y-%m-'), '01')
      and sy.mfgdate < DATE_FORMAT((CURDATE()), '%Y-%m-%d')
    group by sy.mfgdate, sy.area, sy.area1
    union all
##查询计划累加
    select 'plan' type, 'sum', t.mfgdate, t.area, t.area1,
            sum(t.target) over(partition by t.area1 order by mfgdate)
    from (select pl.area, area1, mfgdate, sum(outputb) / 1000 target
          from outputtargetsetting pl
          where 1 = 1
            and pl.mfgdate >= CONCAT(dATE_FORMAT(now() - 8.5 / 24, '%Y-%m-'), '01')
            and pl.mfgdate <= DATE_FORMAT((LAST_DAY(CURDATE())), '%Y-%m-%d')
          group by area1, mfgdate
          order by area1, mfgdate) t
    group by t.mfgdate, t.area, t.area1
    union all
##查询实际产量累加
    select 'actual' type, 'sum', t.mfgdate, t.area, t.area1,
           sum(t.yield) over(partition by t.area1 order by mfgdate)
    from (select sy.area, area1, mfgdate, sum(qcweight) / 1000 yield
          from siteonlinecrucibleyield sy
          where 1 = 1
            and sy.mfgdate >= CONCAT(dATE_FORMAT(now() - 8.5 / 24, '%Y-%m-'), '01')
            and sy.mfgdate < DATE_FORMAT((CURDATE()), '%Y-%m-%d')
          group by area1, mfgdate
          order by area1, mfgdate) t
    group by t.mfgdate, t.area, t.area1;