mysql滑动聚合
滑动聚合是按顺序对滑动窗口范围内的数据进行聚合的操作。下累积聚合不同,滑动聚合并不是统计开始计算的位置到当前位置的数据。
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_ADD(a.ordermonth, INTERVAL -3 MONTH)
AND b.ordermonth <= a.ordermonth
WHERE DATE_FORMAT(a.ordermonth,'%Y')='2015' AND DATE_FORMAT(b.ordermonth,'%Y')='2015'
GROUP BY a.empid,DATE_FORMAT(a.ordermonth, '%Y-%m'),a.qty
ORDER BY a.empid,a.ordermonth
SELECT
a.empid,
a.ordermonth 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_ADD(a.ordermonth, INTERVAL -3 MONTH)
AND b.ordermonth <= a.ordermonth
WHERE DATE_FORMAT(a.ordermonth,'%Y')='2015' AND DATE_FORMAT(b.ordermonth,'%Y')='2015' AND a.empid=1
GROUP BY a.empid,DATE_FORMAT(a.ordermonth, '%Y-%m'),a.qty
HAVING MIN(b.ordermonth)=DATE_ADD(a.ordermonth, INTERVAL-2 MONTH)
ORDER BY a.empid,a.ordermonth
运行结果如下
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWgAAADRCAIAAABuNb+LAAAapklEQVR4nO2dzW7cSLKF+VRGgU/g17iSwYWewtuu9gDc+RmEGbdlDMAH8EbLQVtubwq4Mz2eO3MvejHdPbbkHxl5FySTkRmRIVJikRnB+EAYciqLPJEsnuJP5VHxxxd/tsUWW2yZtBR/fPFnZxiGMQVJxvH777+vLSEv1A+IxAIlauYhKzLjEIz6AZFYoETNPOKN47fffltbQl6oHxCJBUrUzENWZM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JYAlgCYQupxbC4JYCANGN7IGP+k8+iacd4XbsGaoevhfDDccldF2RkHg5jjZCnUD4jEAiVq5jHj0Ib6AZFYoETNPGYc2lA/IBILlKiZx4xDG+oHRGKBEjXzcMYxKQ7IMIxNkTQOwzCM8ZhxGIYxGTMOwzAmY8ZhGMZkzDgMw5iMGYdhGJMx4zAMYzJmHIZhTOb/AZXGBltefeueAAAAAElFTkSuQmCC" alt="" />
mysql滑动聚合的更多相关文章
- MySQL数据库聚合函数
+++++++++++++++++++++++++++++++++++++++++++标题:MySQL数据库聚合函数时间:2019年2月25日内容:MySQL数据库聚合函数重点:MySQL数据库聚合函 ...
- MySQL之聚合数据(AVG,COUNT,MAX,MIN,SUM)
1.首先我们需要了解下什么是聚合函数 聚合函数aggregation function又称为组函数. 认情况下 聚合函数会对当前所在表当做一个组进行统计. 2.聚合函数的特点 1.每个组函数接收一个参 ...
- MySQL 排错-解决MySQL非聚合列未包含在GROUP BY子句报错问题
排错-解决MySQL非聚合列未包含在GROUP BY子句报错问题 By:授客 QQ:1033553122 测试环境 win10 MySQL 5.7 问题描述: 执行类似以下mysql查询, SEL ...
- MySQL的聚合函数
MySQL的聚合函数 网站:https://www.runoob.com/mysql/mysql-functions.html 函数名 功能描述 count() 计数 sum() 求和 avg() 平 ...
- Over:窗口函数(滑动聚合)
Over 窗口函数在Select 子句中,对查询的结果集进行“滑动-聚合”运算:如果使用count,那么基于滑动窗口的聚合语义同 base+1 累加:如果使用sum,那么基于滑动窗口的聚合语义等同于数 ...
- mysql 从聚合函数group by到sql_mode
说到group by, 想必大家都不陌生, 就是对查询的数据进行分组,我们可以通过该操作实现一些特殊需求,比如去重. 最近在项目中使用HQL:" from TSjrz where CBh = ...
- mysql连续聚合
连续聚合是按时间顺序对有序数据进行聚合的操作. 在下面的救示例中将使用EmpOrders表,该表用于存放每位员工每月发生的订购数量. 运行如下 代码创建EmpOrders表并填充示例数据. CREAT ...
- Mysql 分组聚合实现 over partition by 功能
mysql中没有类似oracle和postgreSQL的 OVER(PARTITION BY)功能. 那么如何在MYSQL中搞定分组聚合的查询呢 先说结论: 利用 group_concat + sub ...
- MySQL分组聚合group_concat + substr_index
场景:给予一张商品售卖表,表中数据为商品的售卖记录,假设表中数据是定时脚本插入的,每个时间段的商品售卖数量不同,根据此表找各个商品的最多售卖数量的数据. 1.数据表 CREATE TABLE `goo ...
随机推荐
- PDF分享:国外优秀数学教材选评
<国外优秀数学教材选评>推荐书目下载 具体内容请查看原内容: http://www.library.fudan.edu.cn/wjzx/list/373-1-20.htm 或者http:/ ...
- IE兼容问题 动态生成的节点IE浏览器无法触发
ie下click()不能操作文档中没有的节点,所以你可以在click()前添加下面的语句 document.body.appendChild( input ); input.style.display ...
- PID control
|—平滑化算法 |—PID控制—|—P控制器编程 |—PD控制编程 |—PID控制编程 |—参数优化 |—实验P.PD.PID对减小系统误差的作用 这里讨论怎么将路径转变成行动指令(生成平滑的路径), ...
- win7里linux虚拟机安装vmware tools(ubuntu12.04)
安装Vmware Tools工具 1.安装linux虚拟机(略) 2.虚拟机去启动,选择虚拟机à设置,“硬件”中选择CD/DVD(IDE),右侧选择“使用ISO镜像文件(M)” -- 文件选择vmw ...
- 小白Monkey学习笔记
Monkey是google提供的一款对Android app进行压力测试工具,基于随机坐标位置,进行点击.滑动.输入等操作. Monkey的环境配置 pc电脑需要配置adb环境 Monkey程序由An ...
- nmap 介绍
原文地址:http://drops.wooyun.org/tips/2002 原文地址:http://infotechbits.wordpress.com/2014/05/04/introductio ...
- 最近一个dish项目的建设思考
系统通用能力的沉淀:a.核心模型的数据沉淀 b.通用服务能力的沉淀 ps1:以前重心主要放在了业务的抽象和通过设计模式来增加可复用的扩展性.局限在于,抽象的范围会被单个业务或者当前的业务所束缚,在更大 ...
- Docker构建其它组件
构建mysql 运行centos7容器 docker run --privileged -dti --name=centos-container centos:7 /usr/sbin/init 查询c ...
- day_7数据类型的相互转换,与字符编码
首先复一下昨天的内容 1:深浅拷贝 1:值拷贝 直接赋值 列表1=列表2 列表1中的任何值发生改变,列表2中的值都会随之改变 2:浅拷贝,列表2=列表1 列表1中存放的值的地址没有改变, ...
- Java 使用 Jxl 实现 Excel 导入导出
开发过程中经常需要用到数据的导入导出功能,之前用的是POI,这次使用JXL,JXL相对于POI来说要轻量简洁许多,在数据量不大的情况下还是非常实用的.这里做一下使用JXL的学习记录.首先需要导入相应的 ...