From 4eb1c6e299f33b326cb858c96cf24d6492cc5250 Mon Sep 17 00:00:00 2001 From: xiaochou164 Date: Fri, 18 Aug 2023 10:12:47 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 报表sql/MTDyield.sql | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 报表sql/MTDyield.sql diff --git a/报表sql/MTDyield.sql b/报表sql/MTDyield.sql new file mode 100644 index 0000000..1edeef8 --- /dev/null +++ b/报表sql/MTDyield.sql @@ -0,0 +1,36 @@ +##查询计划明细 +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 \ No newline at end of file