统计查询-sql
select
--总注册人数
(select COUNT(*) from [YYD_Users_RegInfo]) as TotalCount,
--pc端注册人数
(select COUNT(*) from [YYD_Users_RegInfo] where regPlatform ='pc') as PCTotalCount,
--手机端注册人数
(select COUNT(*) from [YYD_Users_RegInfo] where regPlatform ='mobile') as MobileTotalCount,
--新增总注册人数
(select COUNT(*) from [YYD_Users_RegInfo]
where Convert(varchar(10),RegTime,120) >=Convert(varchar(10),'2016-07-01',120)
and Convert(varchar(10),RegTime,120) <=Convert(varchar(10),'2016-07-06',120) ) as AddTotalCount,
--新增pc端注册人数:
(select COUNT(*) from [YYD_Users_RegInfo] where regPlatform ='pc'
and Convert(varchar(10),RegTime,120) >=Convert(varchar(10),'2016-07-01',120)
and Convert(varchar(10),RegTime,120) <=Convert(varchar(10),'2016-07-06',120)) as AddPCTotalCount,
--新增手机端注册人数
(select COUNT(*) from [YYD_Users_RegInfo] where regPlatform ='mobile'
and Convert(varchar(10),RegTime,120) >=Convert(varchar(10),'2016-07-01',120)
and Convert(varchar(10),RegTime,120) <=Convert(varchar(10),'2016-07-06',120)) as AddMobileTotalCount,
--激活总人数
(select count(distinct USER_ID) from [YYD_Account_Verification] where status =1) as TotalVerification,
--实名认证人数
(select count(distinct USER_ID) from [YYD_Account_Verification] where vtype='ver_realname' and status=1) as TotalRealnameVerification,
--新增激活总人数
(select count(distinct USER_ID) from [YYD_Account_Verification] where status =1
and Convert(varchar(10),createtime,120) >=Convert(varchar(10),'2016-07-01',120)
and Convert(varchar(10),createtime,120) <=Convert(varchar(10),'2016-07-06',120)) as AddTotalVerification,
--新增实名认证人数
(select count(distinct USER_ID) from [YYD_Account_Verification] where vtype='ver_realname' and status=1
and Convert(varchar(10),createtime,120) >=Convert(varchar(10),'2016-07-01',120)
and Convert(varchar(10),createtime,120) <=Convert(varchar(10),'2016-07-06',120)) as AddTotalRealnameVerification,
--累计开户数
(select count(distinct USER_ID) from [YYD_Account_BankAccount] where status =1) as OpenAnAccount
--充值统计
select top 1 (select count(*) from (select distinct user_id from YYD_Account_MoneyRecord where (moneytype='充值' or moneytype='线下充值') and state=1) a) People,
(select count(*) from (select distinct user_id from YYD_Account_MoneyRecord where (moneytype='充值' or moneytype='线下充值') and state=1 and createtime >=convert(varchar(100),'2016-06-29 00:00:00',20) and createtime <=convert(varchar(100),'2016-07-06 23:59:59',20) ) a) NewPeople,
(select count(*) from YYD_Account_MoneyRecord where (moneytype='充值' or moneytype='线下充值') and state=1) Number,
(select count(*) from YYD_Account_MoneyRecord where (moneytype='充值' or moneytype='线下充值') and state=1 and createtime >=convert(varchar(100),'2016-06-29 00:00:00',20) and createtime <=convert(varchar(100),'2016-07-06 23:59:59',20) ) NewNumber,
(select sum(amount) from YYD_Account_MoneyRecord where (moneytype='充值' or moneytype='线下充值') and state=1) Amount,
(select sum(amount) from YYD_Account_MoneyRecord where (moneytype='充值' or moneytype='线下充值') and state=1 and createtime >=convert(varchar(100),'2016-06-29 00:00:00',20) and createtime <=convert(varchar(100),'2016-07-06 23:59:59',20) ) NewAmount,
(select COUNT(*) from YYD_Account_MoneyRecord m inner join YYD_Account_RechargeRecord r on r.ID=m.refid where (moneytype='充值' or moneytype='线下充值') and m.state=1 and (r.recharge_type='0' or recharge_type='chinapay_b2c' or recharge_type='offline')) pcCount,
(select COUNT(*) from YYD_Account_MoneyRecord m inner join YYD_Account_RechargeRecord r on r.ID=m.refid where (moneytype='充值' or moneytype='线下充值') and m.state=1 and r.recharge_type='chinapaywap') MobileCount,
(select SUM(m.amount) from YYD_Account_MoneyRecord m inner join YYD_Account_RechargeRecord r on r.ID=m.refid where (moneytype='充值' or moneytype='线下充值') and m.state=1 and r.recharge_type='chinapaywap') MobileAmount,
(select SUM(m.amount) from YYD_Account_MoneyRecord m inner join YYD_Account_RechargeRecord r on r.ID=m.refid where (moneytype='充值' or moneytype='线下充值') and m.state=1 and (r.recharge_type='0' or recharge_type='chinapay_b2c' or recharge_type='offline')) PcAmount,
(select COUNT(*) from YYD_Account_MoneyRecord m inner join YYD_Account_RechargeRecord r on r.ID=m.refid where (moneytype='充值' or moneytype='线下充值') and m.state=1 and (r.recharge_type='0' or recharge_type='chinapay_b2c' or recharge_type='offline') and m.createtime >=convert(varchar(100),'2016-06-29 00:00:00',20) and m.createtime <=convert(varchar(100),'2016-07-06 23:59:59',20) ) NewPcCount,
(select COUNT(*) from YYD_Account_MoneyRecord m inner join YYD_Account_RechargeRecord r on r.ID=m.refid where (moneytype='充值' or moneytype='线下充值') and m.state=1 and r.recharge_type='chinapaywap' and m.createtime >=convert(varchar(100),'2016-06-29 00:00:00',20) and m.createtime <=convert(varchar(100),'2016-07-06 23:59:59',20) ) NewMobileCount,
(select SUM(m.amount) from YYD_Account_MoneyRecord m inner join YYD_Account_RechargeRecord r on r.ID=m.refid where (moneytype='充值' or moneytype='线下充值') and m.state=1 and r.recharge_type='chinapaywap' and m.createtime >=convert(varchar(100),'2016-06-29 00:00:00',20) and m.createtime <=convert(varchar(100),'2016-07-06 23:59:59',20) ) NewMobileAmount,
(select SUM(m.amount) from YYD_Account_MoneyRecord m inner join YYD_Account_RechargeRecord r on r.ID=m.refid where (moneytype='充值' or moneytype='线下充值') and m.state=1 and (r.recharge_type='0' or recharge_type='chinapay_b2c' or recharge_type='offline') and m.createtime >=convert(varchar(100),'2016-06-29 00:00:00',20) and m.createtime <=convert(varchar(100),'2016-07-06 23:59:59',20) ) NewPcAmount
from YYD_Account_MoneyRecord
--投资统计
select top 1
(select COUNT(*) from YYD_Borrow_BidRecord) BidCount,
(select COUNT(*) from (select distinct bid_user_id from YYD_Borrow_BidRecord ) data)BidUsersCount,
(select sum(amount) from YYD_Borrow_BidRecord) BidAmount,
(select SUM(repay_amount) from YYD_Borrow_RepayRecord where status=0 and repaytype='本金') DHRepayAmount,
(select COUNT(*) from YYD_Borrow_BidRecord where 1=1 {0}) NewBidCount,
(select COUNT(*) from (select distinct bid_user_id from YYD_Borrow_BidRecord where 1=1 {0}) data) NewBidUsersCount,
(select sum(amount) from YYD_Borrow_BidRecord where 1=1 {0}) NewBidAmount,
(select SUM(repay_amount) from YYD_Borrow_RepayRecord where status=1 and repaytype='本金') YHRepayAmount
from YYD_Borrow_BidRecord
统计查询-sql的更多相关文章
- 投资统计查询sql
select COUNT(*) from YYD_Users_RegInfo where regTime between '2016-07-11 00:00:00' and '2016-07-11 2 ...
- 电Call记录统计查询sql
DECLARE @startTime datetimeset @startTime='2016-07-12' SELECT * FROM (--坐席号/电话个数/通话总时长select zuoxi a ...
- Thinkphp查询 1.查询方式 2.表达式查询 3.快捷查询 4.区间查询 5.组合查询 6.统计查询 7.动态查询 8.SQL 查询
1.使用字符串作为条件查询 $user = M('User'); var_dump($user->where('id=1 AND user="蜡笔小新"')->sele ...
- [原创]java WEB学习笔记92:Hibernate学习之路-- -QBC 检索和本地 SQL 检索:基本的QBC 查询,带 AND 和 OR 的QBC,统计查询,排序,分页
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- mysql统计类似SQL语句查询次数
mysql统计类似SQL语句查询次数 vc-mysql-sniffer 工具抓取的sql分析. 1.先用shell脚本把所有enter符号替换为null,再根据语句前后的字符分隔语句 grep -Ev ...
- SQL Fundamentals: 分组统计查询(FROM-WHERE-GROUPBY-HAVING-SELECT-ORDER BY)
SQL Fundamentals || Oracle SQL语言 统计函数 单字段分组统计(GROUP BY) 多字段分组统计 HAVING子句 控制操作的显示列:基本的SELECT语句 控制行:限定 ...
- mysql按年度、季度、月度、周、日统计查询的sql语句
本文介绍一些mysql中用于查询的sql语句,包括按年度.季度.月度.周.日统计查询等,有需要的朋友,可以参考下. 一.年度查询 查询 本年度的数据 SELECT * FROM blog_arti ...
- thinkphp区间查询、统计查询、SQL直接查询
区间查询 $data['id']=array(array('gt',4),array('lt',10));//默认关系是(and)并且的关系 //SELECT * FROM `tp_user` WHE ...
- 010.简单查询、分组统计查询、多表连接查询(sql实例)
-------------------------------------day3------------ --添加多行数据:------INSERT [INTO] 表名 [(列的列表)] --SEL ...
随机推荐
- 没办法,还是要补一下js,回调函数(转载)
<html> <head> <title>回调函数(callback)</title> <script language="javasc ...
- [js] 跨域
原文链接:http://www.cnblogs.com/scottckt/archive/2011/11/12/2246531.html 什么是跨域? 首先什么是跨域,简单地理解就是因为JavaScr ...
- Android_进化史和平台架构介绍
一.Android平台发展史 2008年9月,谷歌正式发布了Android 1.0系统,全球第一台Android设备HTC (G1) 2009年4月,谷歌正式推出了Android 1.5 ...
- [转]Oracle中INITRANS和MAXTRANS参数
每个块都有一个块首部.这个块首部中有一个事务表.事务表中会建立一些条目来描述哪些事务将块上的哪些行/元素锁定.这个事务表的初始大小由对象的INITRANS 设置指定.对于表,这个值默认为2(索引的IN ...
- 多线程调用HttpWebRequest并发连接限制
.net 的 HttpWebRequest 或者 WebClient 在多线程情况下存在并发连接限制,这个限制在桌面操作系统如 windows xp , windows 7 下默认是2,在服务器操作 ...
- [Selenium] 使用Javascript选中Input框里的内容,然后清空
当我们需要清空Input框里的内容,直接使用el.clear()方法又行不通时,可以使用Javascript先去选中内容,然后再使用el.clear()方法:
- Druid 数据库用户密码加密 代码实现
druid-1.0.16.jar 阿里巴巴的开源数据连接池 jar包 明文密码+私钥(privateKey)加密=加密密码 加密密码+公钥(publicKey)解密=明文密码 程序代码如下: pack ...
- task-clph
@UI方面 1 UILabel如果没有text内容,那么无论你怎么设置背景色都没用 UIButton就都可以用 2使用了新控件:UIStackView 使用步骤: //1创建 _horizontalS ...
- 联想VIBE UI 固件ROM刷机包集合
固件下载_联想乐问吧http://ask.lenovomobile.com/?c-157.html 联想VIBE UI 固件ROM刷机包集合 悬赏分:0 解决时间:2014/09/12 15: ...
- python核心编程第六章练习6-8
6-8.列表.给出一个整型值,返回代表该值得英文,比如输入89会返回“eight-nine”.附加题:能够返回符合英文语法规律的新式,比如输入89会返回“eighty-nine”.本练习中的值假定在0 ...