最新电Call记录统计-full hash join用法
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用法的更多相关文章
- 电Call记录统计查询sql
DECLARE @startTime datetimeset @startTime='2016-07-12' SELECT * FROM (--坐席号/电话个数/通话总时长select zuoxi a ...
- SWAP_JOIN_INPUTS Oracle Hint(处理hash join强制大表(segment_size大)作为被驱动表)
SWAP_JOIN_INPUTS Oracle Hint(处理hash join强制大表(segment_size大)作为被驱动表) swap_join_inputs是针对哈希连接的hint,它的含义 ...
- [20180705]关于hash join 2.txt
[20180705]关于hash join 2.txt --//昨天优化sql语句,执行计划hash join right sna,加入一个约束设置XX字段not null,逻辑读从上万下降到50.- ...
- oracle Hash Join及三种连接方式
在Oracle中,确定连接操作类型是执行计划生成的重要方面.各种连接操作类型代表着不同的连接操作算法,不同的连接操作类型也适应于不同的数据量和数据分布情况. 无论是Nest Loop Join(嵌套循 ...
- 一种特殊场景下的HASH JOIN的优化为NEST LOOP.
应用场景: 有如下的SQL: select t.*, t1.ownerfrom t, t1where t.id=t1.id; 表t ,t1的数据量比较大,比如200W行.但是两张表能关联的行数却很少, ...
- MySQL8.0 新特性 Hash Join
概述&背景 MySQL一直被人诟病没有实现HashJoin,最新发布的8.0.18已经带上了这个功能,令人欣喜.有时候在想,MySQL为什么一直不支持HashJoin呢?我想可能是因为MySQ ...
- Sort merge join、Nested loops、Hash join(三种连接类型)
目前为止,典型的连接类型有3种: Sort merge join(SMJ排序-合并连接):首先生产driving table需要的数据,然后对这些数据按照连接操作关联列进行排序:然后生产probed ...
- Sql优化(一) Merge Join vs. Hash Join vs. Nested Loop
原创文章,首发自本人个人博客站点,转载请务必注明出自http://www.jasongj.com Nested Loop,Hash Join,Merge Join介绍 Nested Loop: 对于被 ...
- Oracle 表的连接方式(2)-----HASH JOIN的基本机制3
HASH JOIN的模式 hash join有三种工作模式,分别是optimal模式,onepass模式和multipass模式,分别在v$sysstat里面有对应的统计信息: SQL> sel ...
随机推荐
- c point ccccc
代码来自<K&R> 范例输入(控制台): -32 23 11 1833987 23^Z 范例输出: -322311183398723 #include<stdio.h> ...
- jquery使用技巧
1. 禁用右键点击(Disable right-click) <!DOCTYPE html> <html> <head> <meta charset=&quo ...
- poj1474Video Surveillance(半平面交)
链接 半平面交的模板题,判断有没有核.: 注意一下最后的核可能为一条线,面积也是为0的,但却是有的. #include<iostream> #include <stdio.h> ...
- 转:strcpy实现的考察要点
strcpy函数的实现 已知strcpy函数的原型是: char *strcpy(char *dst, const char *src); 实现strcpy函数 解释为什么要返回char * 假如考虑 ...
- 转:如何学习SQL(第四部分:DBMS扩展功能与SQL高级话题)
转自:http://blog.163.com/mig3719@126/blog/static/285720652010950102575/ 9. DBMS提供的扩展功能 掌握了基本的关系模型原理和DB ...
- Js_字符串操作
字符串操作方法 charAt()以单字符串的形式返回给定位置的哪个字符串 例: var num = "hello world"; alert(num.charAt(1))//“e” ...
- 转!!常用的4种动态网页技术—CGI、ASP、JSP、PHP
1.CGI CGI(Common Gateway Interface,公用网关接口)是较早用来建立动态网页的技术.当客户端向Web服务器上指定的CGI程序发出请求时,Web服务器会启动一个新的进程 ...
- iOS开发 自定义窗口 以及 点击scrollView置顶
static UIWindow *topWindow_; static UIScrollView *scrollView_; /** * 显示顶部窗口 */ + (void)show { dispat ...
- JavaScript设计模式与开发实践 - 策略模式
引言 本文摘自<JavaScript设计模式与开发实践> 在现实中,很多时候也有多种途径到达同一个目的地.比如我们要去某个地方旅游,可以根据具体的实际情况来选择出行的线路. 如果没有时间但 ...
- 能源项目xml文件标签释义--<mvc:annotation-driven>
<mvc:annotation-driven />的可选配置 <mvc:annotation-driven message-codes-resolver ="bean re ...