作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想插入到新行,并将今年的总和+上一年的值插入到今年的新rawwiend
示例
in 2014-01-01 sum off all values of rainfall = 2245 for 2013 and sum for 2012 = 2250 when 2014-01-01 should insert new raw to table 2013 values is 2245+2250
我该怎么做........请帮助我,我可以从这段代码中获取2013年的总和,但是我如何添加到上一年的值并将总和插入到表格年份作为2013年
INSERT IGNORE INTO `clima_data`.`mas_aver_curve` ( `year` , `cumulative` )
SELECT year(str_to_date(date, '%m/%d/%Y'))as year round(sum(rainfall),1)
FROM reg_data3 G
GROUP BY year(date) ;
最佳答案
你在找这个吗?
INSERT INTO mas_aver_curve (year, cumulative)
SELECT '2014-01-01', ROUND(SUM(rainfall), 1) rainfall
FROM reg_data3 G
WHERE date >= '2012-01-01'
AND date < '2014-01-01';
这里是SQLFiddle 演示
关于mysql - 上一年的值应添加到当年的值并给出总和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20278646/
基本上,我创建了一个函数,可以显示以下输出: Jan - Mar 24.00 Feb - Apr 25.00 Mar - May 26.00 Apr - Jun 27.00 May - Jul 28.
我是一名优秀的程序员,十分优秀!