统计查询-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 ...
随机推荐
- 期权交易基本原理——买进看跌期权(Long Put),卖出看跌期权(Short Put)
期权交易基本原理--买进看跌期权(Long Put),卖出看跌期权(Short Put) 来源:中电投先融期货-青岛 浏览:13508次2014-07-25 14:25:55 3 第三节 买进看跌期权 ...
- DBCP、C3P0、Proxool 、 BoneCP开源连接池的比《转》
简介 使用评价 项目主页 DBCP DBCP是一个依赖Jakarta commons-pool对象池机制的数据库连接池.DBCP可以直接的在应用程序用使用 可以设置最大和最小连接,连接等待时 ...
- 12 Using_explain_plan
The row source tree is the core of the execution plan. The tree shows the following information: An ...
- Python学习(5)条件语句
目录 Python 条件语句 Python 简单的语句组 Python 条件语句 Python条件语句是通过一条或多条语句的执行结果(True或者False)来决定执行的代码块. 可以通过下图来简单了 ...
- iOS开发之 在release版本禁止输出NSLog内容
因为NSLog的输出还是比较消耗系统资源的,而且输出的数据也可能会暴露出App里的保密数据,所以发布正式版时需要把这些输出全部屏蔽掉. 我们可以在发布版本前先把所有NSLog语句注释掉,等以后要调试时 ...
- 三大平衡树(Treap + Splay + SBT)总结+模板[转]
Treap树 核心是 利用随机数的二叉排序树的各种操作复杂度平均为O(lgn) Treap模板: #include <cstdio> #include <cstring> #i ...
- javascript算术运算符详解
算术运算符 +.-.*./.%.++.-- ++.--分为前缀形式和后缀形式 前缀形式先加减1在执行 后缀形式先执行再加减1 注意 +号用来连接两个字符串 只要+连接的操作数中有一个是字符串型,JS就 ...
- fetchField 和 fetchColumn
public function fetchField($index = 0) { // Call PDOStatement::fetchColumn to fetch the field. retur ...
- drush cc all 报错
请看好 指明了Module文件的行数 报错一定要多看看哦.
- 项目解析- JspLibrary - part2
banner.jsp 验证用户是否登录 <%String manager=(String)session.getAttribute("manager"); //验证用户是否登 ...