带有选择联合进程的MySQL更新表

时间:2019-04-04 10:08:00

标签: mysql select union

嗨,我有一个mysql代码,该表会生成带有选择联合过程的表。 我需要重写此代码,以便启用更新的表。我将介绍一个可以更新表格的每月自动脚本。如何只为更新重写代码:

这是我的工作代码:

select year,month,sum(SumQuantity) as SumIbuprofene,sum(AvgTemp) as AvgTemp, sum(AvgHum) as AvgHum
from
(
select YEAR(cervicale.`event_date`)as year,month(cervicale.`event_date`)as month,SUM(cervicale.`quantity`) as SumQuantity,0 as AvgTemp,0 as  AvgHum
from cervicale 
GROUP BY year(cervicale.`event_date`), month(cervicale.`event_date`)
union
select year(s2.`Time`)as year,month(s2.`Time`)as month, 0,avg(s2.`Temperature`) as AvgTemp, avg(s2.`Humidity`) as AvgHum from s2
GROUP BY year(s2.`Time`), month(s2.`Time`)
)A group by year, month;

0 个答案:

没有答案