最新电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 ...
随机推荐
- iOS - UILabel
前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UILabel : UIView <NSCoding> @available(iOS 2.0, *) p ...
- java实现excel与mysql的导入导出
注意:编码前先导入poi相关jar包 1 /** * 读excel 到list * * @param file excel file * @param fields 字段数组 * @return * ...
- jQuery插件开发全解析,类级别与对象级别开发
jQuery插件的开发包括两种: 一种是类级别的插件开发,即给jQuery添加新的全局函数,相当于给jQuery类本身添加方法.jQuery的全局函数就是属于jQuery命名空间的函数,另一种是对象级 ...
- 最牛B的编码套路(转)
转自:http://blog.csdn.net/happydeer/article/details/17023229 最近,我大量阅读了Steve Yegge的文章.其中有一篇叫"Pract ...
- java 内部类2(成员内部类)
成员内部类: 特点:在其所在的外部类,的成员函数中,的类. 难点:看注释(涉及到jvm) /*test()执行完毕时,x2从内存中消失,inner的声明周,比x2长,inner还在访问,给人的感觉好像 ...
- android:layout_weight的真实含义
首先声明只有在Linearlayout中,该属性才有效.之所以android:layout_weight会引起争议, 是因为在设置该属性的同时,设置android:layout_width为wrap_ ...
- Event 讲解
应用场景:某件事发生时,需要采取多步的动作,此时就用到了 使用方法:创建event方法一,使用命令 make:event 生成事件在app/Events目录下,命令make:listener 生成监 ...
- spring来了-02-HelloWorld
spring的各个版本说明: 在3.0以下的版本,源码有spring中相关的所有包[spring功能+依赖包],如:2.5版本 在3.0以上的版本,源码中只有spring的核心功能包[没有依赖包],如 ...
- 【LINUX】Linux学习小结
****xargs命令**** 当需要将参数列表转换成小块分段传递给其他命令时,可以使用xargs命令.栗子如下: 若想在启动lampp之后用kill方式杀掉全部的进程就可以用下面的命令: ps -e ...
- Junit4入门
eclipse自带junit包,可右键直接新建junit类 静态引入:import static org.junit.Assert.* assert.*是类,静态引入会引入assert里的所有静态方法 ...