declare @time datetime
set @time='2016-07-01'

--最新的电Call记录统计查询
--SELECT t.zuoxi1,t.PhoneCount,t.PhoneCountSC,t.zuoxi2,t.RegUserCount,t.zuoxi3,t.RechargeAmount,
SELECT ISNULL(ISNULL(t.zuoxi1,(ISNULL(t.zuoxi2,t.zuoxi3))),t.zuoxi4) as zuoxi,t.PhoneCount,t.PhoneCountSC,t.zuoxi2,t.RegUserCount,t.zuoxi3,t.RechargeAmount,

t.zuoxi4,t.BidAmount from(
select * from
(
--坐席号/电话个数/通话总时长
select zuoxi as zuoxi1,COUNT(1) as PhoneCount,SUM(DATEDIFF(ss,jtDate,endDate)) PhoneCountSC from HUR_TelCallRecord where vdef2=1 and
Convert(varchar(10),jtDate,120)='2016-07-20'
--DATEDIFF(day,jtdate,'2016-06-25')<15
group by zuoxi
) as tel
full hash join
(
----注册用户数
SELECT tr.zuoxi as zuoxi2,COUNT(distinct u.user_id) as RegUserCount FROM [dbo].YYD_Users_UserInfo u INNER JOIN YYD_Users_RegInfo r ON u.user_id=r.id RIGHT JOIN [HUR_TelCallRecord] tr ON u.phone=tr.phone
WHERE CONVERT(VARCHAR(10), RegTime,120)= '2016-07-20' AND
DATEDIFF(DAY,tr.jtDate,'2016-07-20')<15 AND DATEDIFF(DAY,tr.jtDate,'2016-07-20')>0
GROUP BY zuoxi
)
as reg
on reg.zuoxi2=tel.zuoxi1
full hash join
(
--充值总金额
SELECT tr.zuoxi as zuoxi3,sum(amount) as RechargeAmount FROM YYD_Account_MoneyRecord m left JOIN YYD_Users_UserInfo u ON m.user_id=u.user_id RIGHT JOIN
[HUR_TelCallRecord] tr ON u.phone=tr.phone
WHERE (moneytype='充值' or moneytype='线下充值' ) and state=1 and CONVERT(VARCHAR(10), paytime,120)='2016-07-20' and
DATEDIFF(DAY,tr.jtDate,'2016-07-20')<15 AND DATEDIFF(DAY,tr.jtDate,'2016-07-20')>0
GROUP BY zuoxi
) as re
on re.zuoxi3=tel.zuoxi1
full hash join
(
--投资总金额
SELECT tr.zuoxi as zuoxi4,sum(amount) as BidAmount FROM YYD_Borrow_BidRecord m left JOIN YYD_Users_UserInfo u ON m.bid_user_id=u.user_id RIGHT JOIN [HUR_TelCallRecord] tr ON u.phone=tr.phone
WHERE m.status=1 and CONVERT(VARCHAR(10), createtime,120)='2016-07-20'
and borrow_id in(select borrow_id from YYD_Borrow_borrowinfo_ext as ext where ext.borrow_product<>50) and
DATEDIFF(DAY,tr.jtDate,'2016-07-20')<15 AND DATEDIFF(DAY,tr.jtDate,'2016-07-20')>0
GROUP BY zuoxi
)as bid
on bid.zuoxi4 = tel.zuoxi1
WHERE tel.zuoxi1 IS NOT NULL
) as t order by PhoneCountSC desc

--充值表
select * from YYD_Account_MoneyRecord order by ID desc

where state=1 and CONVERT(VARCHAR(10), paytime,120)='2016-06-25'

update YYD_Account_MoneyRecord set user_id=83946,paytime='2016-06-25 10:00:41.232',state=1,moneytype='充值' where ID=12399
--投资表
select * from YYD_Borrow_BidRecord order by ID desc
update YYD_Borrow_BidRecord set createtime='2016-06-25 11:00:23.211',bid_user_id=83946,bid_user_account='13025874103',status=1 where ID=5820

--YYD_Borrow_BorrowInfo
select * from YYD_Borrow_BorrowInfo order by ID desc
update YYD_Borrow_BorrowInfo set user_id=83946 where ID=1882

select * from YYD_Users_RegInfo where ID=83946 where CONVERT(VARCHAR(10), RegTime,120)= '2016-06-25' order by ID

select * from [HUR_TelCallRecord] where phone=13025874103 order by id desc

update [HUR_TelCallRecord] set phone=13025874166 where id=104212 or id=104210 or id=104212

update [HUR_TelCallRecord] set vdef2=1 where id=104209 or id=104206

select * from YYD_Users_UserInfo as u where phone in(select phone from [HUR_TelCallRecord] as t)

select * from [HUR_TelCallRecord] where phone=13025874103 order by id desc

select * from YYD_Users_RegInfo as a where ID in(select b.user_id from YYD_Users_UserInfo as b where a.ID = b.user_id)

order by ID desc

select * from YYD_Users_UserInfo where user_id=1144

select * from YYD_Borrow_BidRecord where bid_user_id =1239

select * from HUR_TelCallRecord order by jtDate desc

select * from HUR_TelCallRecord where vdef2=1 and
Convert(varchar(10),jtDate,120)='2016-07-01' order by id desc

--可以查询出那个坐席号是空的
select zuoxi as zuoxi1,COUNT(1) as PhoneCount,SUM(DATEDIFF(ss,jtDate,endDate)) PhoneCountSC,id from HUR_TelCallRecord where vdef2=1 and
Convert(varchar(10),jtDate,120)='2016-07-01'
group by zuoxi,id

最新电Call记录统计-full hash join用法的更多相关文章

  1. 电Call记录统计查询sql

    DECLARE @startTime datetimeset @startTime='2016-07-12' SELECT * FROM (--坐席号/电话个数/通话总时长select zuoxi a ...

  2. Sort merge join、Nested loops、Hash join(三种连接类型)

    目前为止,典型的连接类型有3种: Sort merge join(SMJ排序-合并连接):首先生产driving table需要的数据,然后对这些数据按照连接操作关联列进行排序:然后生产probed ...

  3. Sql优化(一) Merge Join vs. Hash Join vs. Nested Loop

    原创文章,首发自本人个人博客站点,转载请务必注明出自http://www.jasongj.com Nested Loop,Hash Join,Merge Join介绍 Nested Loop: 对于被 ...

  4. Oracle 表的连接方式(2)-----HASH JOIN的基本机制3

    HASH JOIN的模式 hash join有三种工作模式,分别是optimal模式,onepass模式和multipass模式,分别在v$sysstat里面有对应的统计信息: SQL> sel ...

  5. Oracle 表的连接方式(2)-----HASH JOIN的基本机制2

    Hash算法原理 对于什么是Hash算法原理?这个问题有点难度,不是很好说清楚,来做一个比喻吧:我们有很多的小猪,每个的体重都不一样,假设体重分布比较平均(我们考虑到公斤级别),我们按照体重来分,划分 ...

  6. Oracle 表的连接方式(2)-----HASH JOIN的基本机制1

    我们对hash join的常见误解,一般包括两个: 第一个误解:是我们经常以为hash join需要对两个做join的表都做全表扫描 第二个误解:是经常以为hash join会选择比较小的表做buil ...

  7. SQL Server的三种物理连接之Hash Join(三)

    简介 在 SQL Server 2012 在一些特殊的例子下会看到下面的图标: Hash Join分为两个阶段,分别为生成和探测阶段. 首先是生成阶段,将输入源中的每一个条目经过散列函数的计算都放到不 ...

  8. Nested Loop,Sort Merge Join,Hash Join

    三种连接工作方式比较: Nested loops 工作方式是从一张表中读取数据,访问另一张表(通常是索引)来做匹配,nested loops适用的场合是当一个关联表比较小的时候,效率会更高. Merg ...

  9. 并行HASH JOIN小表广播问题

    SQL语句: SELECT /*+parallel(t1 16)*/ T1.DATA_DATE, T1.ACCT_NO, T1.ACCT_ORD, T1.ACCT_NO_PK, T1.ACCT_BAL ...

随机推荐

  1. div 指令

    div 指令 div 是除法指令,后面跟的是除数,被除数默认在 ax, 或者 dx.ax 组成的存储单元中. 除数可以有 8 位和 16 位两种,存储于一个 reg 或内存单元中,也就是说不可以 di ...

  2. LED数码管显示实验

    1.代码: #include <reg52.h>typedef unsigned char  u8;typedef unsigned int   u16;sbit seg_sel = P1 ...

  3. [CareerCup] 18.7 Longest Word 最长的单词

    5.7 Given a list of words, write a program to find the longest word made of other words in the list. ...

  4. JS事件委托学习(转)

    JS 事件委托就是利用冒泡原理,把事件加到父级上触发,执行效果. 好处: 1.提高性能 2.新添加的元素还会有之前的事件     <</</</</li></ ...

  5. Android手机 Fildder真机抓包

    Fiddler是一个http调试代理,它能 够记录所有的你电脑和互联网之间的http通讯,Fiddler 可以也可以让你检查所有的http通讯,设置断点,以及Fiddle 所有的“进出”的数据(指co ...

  6. 基础知识《零》---Java程序运行机制及运行过程

    Java运行机制 Java虚拟机(Java Virtual Machine):Java虚拟机可以理解成一个以字节码为机器指令的CPU:对于不同的运行平台,有不同的虚拟机:Java虚拟机机制屏蔽了底层运 ...

  7. MyEclipse 设置注释

    MyEclipse设置注释的方法 windows-Preferences-(弹出窗口) 单击[Edit]后弹出编辑窗口,然后进行编辑

  8. ListIterator-迭代器

    Iterable(lang)-->Iterator(util)-->ListIterator(util) method: 1.void add(E o) 2.boolean hasNext ...

  9. Mac电脑svn使用经验,Mac电脑使用android studio使用经验

    1.先查看mac本身是否自带java1.6 没有去appstore里面安装 2.http://www.android-studio.org/   下载mac版的ide 3.安装完成ide后,打开and ...

  10. 【6】了解Bootstrap栅格系统基础案例(1)

    从上一张我们了解了栅格选项,那么我们就来了实战了解下吧(其实还是中文官网的案例) ps.我这里是电脑上用谷歌浏览器来观察的,毕竟电脑的分辨率高(1440*900px),谷歌浏览器最大化后,值比大屏幕设 ...