--先找到档期
select * from hv_item_info a where a.report_begdate > '2016-07-28' and a.report_begdate < '2016-07-29';

--找轮次
select * from media_item_wheel_info a where a.item_id = 46088 and a.rule_id = 0215 order by a.begin_date;

--按键情况
select * from media_user_dial_info a where a.item_id = 46088 and a.item_wheel_id in ('74419');

--中奖人数
select * from media_prizerl_info a where a.item_id = 46088 and a.item_wheel_id in ('74419');

--开始前在线人数
select * from (
select t.callingnbr,
t.callednbr,
t.flag,
lead(t.flag, 1, null) over(partition by t.callingnbr, t.callednbr order by t.logdate) nextflag,
t.logdate,
lead(t.logdate, 1, null) over(partition by t.callingnbr, t.callednbr order by t.logdate)
from MEDIA_USER_ONLINE_OFFLINE_LOG t
where t.callednbr in ('12590484666', '12590484667')
and t.flag <> 'DD'
and t.logdate >= to_Date('20160728105000', 'yyyymmddhh24miss')
and t.logdate <= to_Date('20160728113739', 'yyyymmddhh24miss')) a
where a.flag = 'on' and nextflag is null;

--结束时的在线人数
select * from (
select t.callingnbr,
t.callednbr,
t.flag,
lead(t.flag, 1, null) over(partition by t.callingnbr, t.callednbr order by t.logdate) nextflag,
t.logdate,
lead(t.logdate, 1, null) over(partition by t.callingnbr, t.callednbr order by t.logdate)
from MEDIA_USER_ONLINE_OFFLINE_LOG t
where t.callednbr in ('12590484666', '12590484667')
and t.flag <> 'DD'
and t.logdate >= to_Date('20160728105000', 'yyyymmddhh24miss')
and t.logdate <= to_Date('20160728113749', 'yyyymmddhh24miss')) a
where a.flag = 'on' and nextflag is null;

抢凳子日数据sql的更多相关文章

  1. 全国省市级联数据sql语句 mysql版

    全国省市级联数据sql语句 mysql版 --省级 provincial create table provincial ( provincialID int, provincialName ), p ...

  2. 最强最全面的大数据SQL经典面试题(由31位大佬共同协作完成)

    本套SQL题的答案是由许多小伙伴共同贡献的,1+1的力量是远远大于2的,有不少题目都采用了非常巧妙的解法,也有不少题目有多种解法.本套大数据SQL题不仅题目丰富多样,答案更是精彩绝伦! 注:以下参考答 ...

  3. SQLServer2008 和SQLServer2008 R2版本导出 数据库结构和数据sql

    ①SQLServer2008 版本导出 数据库结构和数据sql ②SQLServer2008R2 版本导出 数据库结构和数据sql 采集 #HUABAN_WIDGETS .HUABAN-red-nor ...

  4. 跨服务器导入数据SQL语句及其问题解决方案

    --跨服务器导入数据SQL语句: insert into [shsw_manager].[dbo].[Station_List]select * from OPENROWSET('SQLOLEDB', ...

  5. 开发一个不需要重写成Hive QL的大数据SQL引擎

    摘要:开发一款能支持标准数据库SQL的大数据仓库引擎,让那些在Oracle上运行良好的SQL可以直接运行在Hadoop上,而不需要重写成Hive QL. 本文分享自华为云社区<​​​​​​​​​ ...

  6. BCP 导出导入数据(SQL Server)

    BCP指令工具可通过安装SQL Server获得. 1. 根据现有的数据库生成表的format文件(导入导出数据的时候需要) bcp db_test.dbo.Table1 format nul -c ...

  7. 提高mysql千万级大数据SQL查询优化30条经验(Mysql索引优化注意)

    转自http://blog.163.com/zhangjie_0303/blog/static/9908270620146951355834/ 1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 w ...

  8. (转)提高mysql千万级大数据SQL查询优化30条经验(Mysql索引优化注意)

    1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索 ...

  9. 9月18日,SQL学习基础1

    数据库管理和应用 Oltp是小型的管理,OLAP是大型的管理 开发的内容如触发器 数据库管理系统(Database Management System,简称为DBMS)是位于用户与操作系统之间的一层数 ...

随机推荐

  1. logstash 配置 logstash-forwarder (前名称:lumberjack)

    logstash-forwarder(曾名lumberjack)是一个用go语言写的日志发送端, 主要是为一些机器性能不足,有性能强迫症的患者准备的. 主要功能: 通过配置的信任关系,把被监控机器的日 ...

  2. [POJ2151]Check the difficulty of problems (概率dp)

    题目链接:http://poj.org/problem?id=2151 题目大意:有M个题目,T支队伍,第i个队伍做出第j个题目的概率为Pij,问每个队伍都至少做出1个题并且至少有一个队伍做出N题的概 ...

  3. 【转】Python资源 转自 dylanninin.com

    http://dylanninin.com/blog/2013/11/23/python_resource.html Python是在工作期间零零碎碎学习起来的.当时正值部门申购图书,鉴于Python ...

  4. linux命令之chmod 2011.11.24转载于网络

    使用权限 : 所有使用者 使用方式 : chmod [-cfvR] [--help] [--version] mode file... 说明 : Linux/Unix 的档案调用权限分为三级 : 档案 ...

  5. js 获取当前日期时间3种格式化方法 yyyy-mm-dd hh:MM:ss

    方法一: Date.prototype.format = function (format) { var args = { "M+": this.getMonth() + 1, & ...

  6. 使用ab进行压力测试

    在Windows系统的命令行下,进入ab.exe程序所在目录,执行ab.exe程序.注意直接双击无法正确运行.

  7. Windows Server 2008 R2 服务器安装(重装)流程备忘

    系统相关 一.安装Windows Server R2 (略) 二.激活系统:Windows Loader 三.创建域 (自行参考: http://www.cnblogs.com/zhongweiv/a ...

  8. Yaf框架下类的自动加载

    前面两篇博客分别讲述了PHP自带的类加载和composer中类的自动加载,其实Yaf框架也实现了基于PSR0和PSR4的类的自动加载.根据我对Yaf下类的自动加载方式的理解写下这篇博客.由于接触Yaf ...

  9. $.getJSON在IE8下失效

    $.getJSON("/Home/GetData?r=" + Math.random(), { ids: ids }, function(data) { //处理逻辑 }); 原因 ...

  10. ShellExecute —— 运行一个外部程序

    原型参数 注意事项:使用该函数时,需添加该头文件:[1]  #include <shellapi.h> ShellExecute函数原型及参数含义如下: ShellExecute( hWn ...