YZ_MES/报表sql/可视化/MTDyield.sql

36 lines
1.6 KiB
SQL

##
SELECT DISTINCT 'plan' type,pl.mfgdate,pl.area,pl.area1,pl.prod,pl.crusize,pl.crucible,pl.outputb/1000 outputb
from 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')
union all
##
SELECT DISTINCT 'plan' type,pl.mfgdate,pl.area,pl.area1,pl.prod,pl.crusize,pl.crucible,
sum(pl.outputb/1000) over(partition by pl.area1 order by pl.mfgdate) as ttloutputb
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,pl.prod,pl.crusize,pl.crucible,pl.outputb
union all
##
SELECT DISTINCT 'actual' type,sy.mfgdate,sy.area,sy.area1,sy.subprod,sy.crusize,sy.crucible,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((LAST_DAY(CURDATE())),'%Y-%m-%d')
union all
##
SELECT DISTINCT 'actual' type,sy.mfgdate,sy.area,sy.area1,sy.subprod,sy.crusize,sy.crucible,
sum(sy.qcweight/1000) over(partition by sy.area1 order by sy.mfgdate) as ttlweight
from siteonlinecrucibleyield sy
where 1=1
and sy.mfgdate >= CONCAT(dATE_FORMAT(now() - 8.5 / 24,'%Y-%m-'),'01')
and sy.mfgdate <= DATE_FORMAT((LAST_DAY(CURDATE())),'%Y-%m-%d')
GROUP BY sy.mfgdate,sy.area,sy.area1,sy.subprod,sy.crusize,sy.crucible,sy.qcweight