年初至今聚合和滑动聚合类似,不同的地方仅在于统计的仅为当前一年的聚合。唯一的区别体现在下限的开始位置上。在年初至今的问题中,下限为该年的第一天,而滑动聚合的下限为N个月的第一天。因此,年初至今的问题的解决方案如下图所示,得到的结果
SELECT
a.empid,
DATE_FORMAT(a.ordermonth, '%Y-%m') AS ordermonth,
a.qty AS thismonth,
SUM(b.qty) AS total,
CAST(AVG(b.qty) AS DECIMAL(5,2)) AS avg
FROM emporders a
INNER JOIN emporders b
ON a.empid=b.empid
AND b.ordermonth >= DATE_FORMAT(a.ordermonth, '%Y-01-01')
AND b.ordermonth <= a.ordermonth
AND DATE_FORMAT(b.ordermonth,'%Y')='2015'
GROUP BY a.empid,a.ordermonth,a.qty
ORDER BY a.empid,a.ordermonth
运行结果如下
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAV0AAAETCAIAAAAauEL8AAAgAElEQVR4nO1dy27cSJblVxkCv8C/MXKBC32Ft5XlBrirbxC6XSVjAH5AbbQctO32JoHph3u6Z+BFq6ptyXapcGdBMngZN+KKKSWD94TigDDSkRR5TjLjZATJe1j9/uV/lqUsZSkLX6rfv/xPKigoKGBA8oVffvllawqbIXvtiAIROetwioovYCB77YgCETnrgPSFn3/+eWsKmyF77YgCETnrcIqKL2Age+2IAhE56yi+AIbstSMKROSsw7Yv7Nu6bvei+erq6ujbXAUr7OtB2iVSfhrLdndkgcfFGl9Ik3CKDPiC/NAjh+Ff//rXMfdydLhdrLCvB2l3UBiu8fkc8oEcR+BCPoe+u8YX0iScosEXfv319ubzVyvLn353cvK7t/PG29vf/vm//3d/nqFtrkX72Pt6qPb1GT5wd0cTuJDPoe+u8YW0t/SKrm++XN98GXzh66+3/f/vv7x9cVL1ONm9/XL99sXJyTenJ1VVVacX73bDi1k7a3nxZraFqupb2HJ7+9v//OOfAZ7TX31zcTNsbfeM/dfbZoDnuH6Ms7YXt86wflVVJ8++Ee8+aIlqP2xRGY5H4c13bqUXb1J9IEcSuFj+d+98/vN3pw+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jSLybAvyLymAWZ84eEMZS5LMMHJwbovyEkEpc5raosvLIfMYho+H8O+IBOc3o8MjfjCwxlm5QtBU6DUeU1lHnEv4IwXJlgdL0QJPLp5xJ7qiClQ8rymRVtIheILKyIzX1DzmiDPO/KwJnmpUjkM6+Q1LdhCKiD6gozeul8Y1+qYJ8d7EUmyxWETX7iboZ7XBHmdUgVM31gB2WtHFIjIWUfxBTBkrx1RICJnHcUXwJC9dkSBiJx1FF8AQ/baEQUictbh+8JBiS4FBQW5YuYLELjKzp6XI3vtiAIROesovgCG7LUjCkTkrKP4Ahiy144oEJGzjuILYMheO6JARM46ii+AIXvtiAIROeuw6gvG85oCe0kE419B7wZ2/gBrnuDUsHXuFa5xBOhJRztWvzg81nV8eOzZQV/II8Hj4z2l9mlzx3NoKZP7oI3nNYm9JINxX+DomsnTvQSnRj7bekQCgUuSjvzS4y7cf3qk8YXY3i8bOmvpvGb+JSwvk7opDrt5TdNeFtA5EmB8YU/12PllgtO2vtDT02slvX542ZM3AK4AAAFYSURBVIR/hHts6QtjcdTkC6Giz1zqrB0s5zX5G0kBFF9wg4VgglNzv0niEbHAF/isgQ/jd8LSUs4jvFlMP1jw1pEWllUuCxnPa0o+iSAUX2CDhWiCExEdOkk8KsPliSbn+/mva7wXJcCOd/tQwsJ5HZgXZOULtvOaNjAFAvEFfmZhQmjod99J4oOx2Bf68TnvOdOIfUTKg8L3Pg0W5uQlw1zmEcbzmsRekgHAF9hgwW/vfcGdVA6tacIXunGyMP4gz3pg+vGC4COZ7CqxTslrmv4wSV5TaC+JYN8X2jo0WCDmC+witDzZm+56xF1JR97ZBBe+Kmfvq3OO8Jmda5DXKUte0+NB9toRBSJy1lF8AQzZa0cUiMhZR/EFMGSvHVEgImcdxRfAkL12RIGInHX4vnBQoktBQUGumPkCBK6ys+flyF47okBEzjqKL4Ahe+2IAhE563CK/h+wvMWZfP8NIwAAAABJRU5ErkJggg==" alt="" />
- Mysql中使用聚合函数对null值的处理
平时因为对于数据库研习的不深,所以在面试的时候问了一些平常遇到过的问题居然没法很肯定地回答出来,实在让自己很恼怒! 这次让我记忆深刻的一个问题是: 在mysql中使用聚合函数的时候比如avg(t),t ...
- mysql 分组和聚合函数
mysql 分组和聚合函数 Mysql 聚集函数有5个: 1.COUNT() 记录个数(count(1),count(*)统计表中行数,count(列名)统计列中非null数) 2.MAX() 最大值 ...
- mysql数据库优化课程---10、mysql数据库分组聚合
mysql数据库优化课程---10.mysql数据库分组聚合 一.总结 一句话总结:select concat(class,' 班') 班级,concat(count(*),' 人') 人数 from ...
- mysql常用的聚合函数
GROUP BY(聚合)函数本章论述了用于一组数值操作的 group (集合)函数.除非另作说明, group 函数会忽略 NULL 值. 假如你在一个不包含 ROUP BY子句的语句中使用一个 gr ...
- [LeetCode]1084. 销售分析III(Mysql,having+聚合函数)
题目 Table: Product +--------------+---------+ | Column Name | Type | +--------------+---------+ | pro ...
- MySQL 常用的聚合函数
[常用的聚合函数] mysql聚合函数一般用户统计一列值进行计算,然后返回计算结果.一般于分组group by 配合使用. count //统计个数 select count(*) from test ...
- 关于mysql中使用聚合函数结果集为空,仍显示size为1,所有元素为Null问题的解决办法
转自:https://www.2cto.com/database/201806/757632.html 1.不使用聚合函数sql: select * from sys_role_data a left ...
- MySQL中的聚合函数
创建student表 CREATE TABLE IF NOT EXISTS `student` ( `id` int(4) unsigned NOT NULL AUTO_INCREMENT, `nam ...
- MySQL数据库:聚合函数的使用
聚合函数 max() 最大值 min() 最小值 avg() 平均值 sum() 求和 count() 符合条件数据的数目 聚合函数不能嵌套使用 # 在统计时字段内没有满足条件的数值只有count返回 ...
随机推荐
- Web表现层
目录 Web表现层调用过程... 2 延迟... 3 什么是延迟... 3 延迟的构成... 3 最基本的优化思路:... 4 Web表现层性能优化... 4 Web性能的基本指标... 4 Web性 ...
- python csv读写
https://blog.csdn.net/taotiezhengfeng/article/details/75577998
- webveiw返回死循环问题以及在打开web页面会唤起浏览器打开的问题解决
微信.QQ空间等大量软件都内嵌了H5,不得不说这是一种趋势,Andriod与H5互调可以让我们实现混合开发.至于混合开发就是在一个App中内嵌一个轻量级的浏览器,一部分原生的功能改为Html 5来开发 ...
- python生成exe文件
安装pyinstaller pyinstaller支持python2和python3 命令行安装:pip install pyinstaller pyinstaller --icon=duoguan. ...
- 《vue.js快跑》总结:为什么选择VUE
2019-3-31 为什么选择Vue 有这个一个需求,我们需要根据后端数据接口请求返回的数组在页面中按列表展示? 传统上我们使用jQuery的Ajax发送http请求,获取数据.判断列表数据是否存在, ...
- XSS攻击 CSRF攻击
XSS攻击: 跨站脚本攻击(Cross Site Scripting),为不和层叠样式表(Cascading Style Sheets, CSS)的缩写混淆, 故将跨站脚本攻击缩写为XSS.恶意攻击者 ...
- influence maximization 第二弹
Robust Influence Maximization 首先简要介绍一下这个问题:在一个社交网络图中寻找固定数量的节点,使得这些节点对所有节点的影响值尽可能的大.先对这个问题给出形式化的定义:给一 ...
- JObject,JArray的基本操作
引用:https://www.cnblogs.com/dacongge/p/6957074.html 1.JObject:基本的json对象 /// <summary> /// Gets ...
- 补发————grid布局
CSS Grid布局是CSS中最强大的布局系统.与flexbox的一位布局不同的是CSS Grid布局是一个二维布局系统,即它可以同时处理列和行.通过将CSS规则应用于父元素和其子元素,就可以轻松使用 ...
- css基础回顾
1.css选择器分类: id选择器,类选择器,通用选择器, 包含(后代)选择器——加入空格,用于选择指定标签元素下的后辈元素. 子选择器(大于符号)——用于指定标签元素的第一代子元素. 伪类选择器—— ...