统计查询-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 ...
随机推荐
- Springmvc中 同步/异步请求参数的传递以及数据的返回
转载:http://blog.csdn.net/qh_java/article/details/44802287 注意: 这里的返回就是返回到jsp页面 **** controller接收前台数据的方 ...
- [转载] 【每周推荐阅读】C-Store:列式存储数据库
Record-based与column-based是数据库和存储系统里面两种不同的data layout.我们的思维逻辑是基于行记录的,即Record-based data layout,数据记录都是 ...
- web设计经验<三>值得你深入了解的交互设计5大支柱
随着单页式设计和移动端的兴起,网页中的交互设计越来越重要了.为了打造流畅而可靠的用户体验,你需要对交互设计有更加深入的了解. 正如同我们在<交互设计最佳实践(卷1)>中所述,要做好交互设计 ...
- MVC中Url请求与控制器的默认约定
1.请求的url如:http://localhost:52481/Home/Browse?genre=1控制器方法:public string Browse(string genre) //这里返回值 ...
- Python学习(10)元组
目录 Python 元组 访问元组 修改元组 删除元组 元组运算符 元组索引,截取 无关闭分隔符 元组内置函数 Python 元组 Python的元组与列表类似,不同之处在于元组的元素不能修改. 元组 ...
- sqlplus命令大全
一.ORACLE的启动和关闭 1.在单机环境下要想启动或关闭ORACLE系统必须首先切换到ORACLE用户,如下su - oracle a.启动ORACLE系统oracle>svrmgrlSVR ...
- 数据字典 dba_free_space及相对文件号RELATIVE_FNO 小结
1.1 dba_free_space 1.1.1 概述 SQL> desc dba_free_space; Name Type Nullable Default Comments ------- ...
- 转!!数据库 第一范式(1NF) 第二范式(2NF) 第三范式(3NF)的 联系和区别
范式:英文名称是 Normal Form,它是英国人 E.F.Codd(关系数据库的老祖宗)在上个世纪70年代提出关系数据库模型后总结出来的,范式是关系数据库理论的基础,也是我们在设计数据库结构过程中 ...
- 安卓虚拟机启动失败intel haxm未安装
1:环境是android studio 在AVD中启动显示,提示当前电脑为安装HAXM emulator: ERROR: x86 emulation currently requires hardwa ...
- Nemo Documents – 给文件添加标签 以日历的形式将文件呈现出来,很像 Outlook,你可以根据年、月、日来查看不同类型的文档
Nemo Documents – 给文件添加标签 scavin(Google+) on 2012.03.28. Nemo Documents 是款文件组织管理工具(文档管理器),不是街道大妈胜似大 ...