select t1.*,
(select sum(月高压蒸汽) from (select month(日期),AVG(1.0*高压蒸汽 / 月产量) as 月高压蒸汽 from 计划处产量和统计报表
where
车间=t1.车间 and
year(日期)=year(t1.日期) and
month(日期)<=month(t1.日期) group by month(日期)) as x) as '累计高压蒸汽'
from 计划处产量和统计报表 as t1
没有测试,不知道对不对
(select sum(月高压蒸汽) from (select month(日期),AVG(1.0*高压蒸汽 / 月产量) as 月高压蒸汽 from 计划处产量和统计报表
where
车间=t1.车间 and
year(日期)=year(t1.日期) and
month(日期)<=month(t1.日期) group by month(日期)) as x) as '累计高压蒸汽'
from 计划处产量和统计报表 as t1
没有测试,不知道对不对
(select sum(月高压蒸汽) from (select month(日期) as 月,AVG(1.0*高压蒸汽 / 月产量) as 月高压蒸汽 from 计划处产量和统计报表
where
车间=t1.车间 and
year(日期)=year(t1.日期) and
month(日期)<=month(t1.日期) group by month(日期)) as x) as '累计高压蒸汽'
from 计划处产量和统计报表 as t1
这是干什么的
这样算出来的结果只是和,还没求平均,是不是应该sum(月高压蒸汽)?
AVG(1.0*高压蒸汽 / 月产量) 是什么意思,我觉得就一个值,自己对自己求平均?