投资统计查询sql

select COUNT(*) from YYD_Users_RegInfo where regTime between ‘2016-07-11 00:00:00‘ and ‘2016-07-11 23:59:59‘
union all select COUNT(*) from YYD_Users_RegInfo where regTime between ‘1980-01-01‘ and ‘2016-07-11 23:59:59‘
union all select sum(amount) from YYD_Account_MoneyRecord
where (moneytype=‘充值‘ or moneytype=‘线下充值‘ ) and state=1 and paytime between ‘2016-07-11 00:00:00‘ and ‘2016-07-11 23:59:59‘
union all select sum(amount) from [YYD_Account_MoneyRecord]
where (moneytype=‘充值‘ or moneytype=‘线下充值‘ ) and state=1 and paytime between ‘1980-01-01‘ and ‘2016-07-11 23:59:59‘

--投资金额(当日)
--union all select sum(amount) from [YYD_Account_MoneyRecord]
--where moneytype in(‘参与投标‘,‘加入计划‘) and state=1 and createtime between ‘2016-07-11 00:00:00‘ and ‘2016-07-11 23:59:59‘
union all select SUM(amount) from YYD_Borrow_BidRecord where status=1
and createtime between ‘2016-07-11 00:00:00‘ and ‘2016-07-11 23:59:59‘
and borrow_id in(select borrow_id from YYD_Borrow_borrowinfo_ext as ext where ext.borrow_product<>50)

--投资金额(总累计)
--union all select sum(amount) from [YYD_Account_MoneyRecord]
--where moneytype in(‘参与投标‘,‘加入计划‘) and state=1 and createtime between ‘1980-01-01‘ and ‘2016-07-11 23:59:59‘
union all select SUM(amount) from YYD_Borrow_BidRecord where status=1 and
createtime between ‘1980-01-01‘ and ‘2016-07-11 23:59:59‘
and borrow_id in(select borrow_id from YYD_Borrow_borrowinfo_ext as ext where ext.borrow_product<>50)

union all select sum(amount) from [YYD_Account_MoneyRecord]
where (moneytype=‘提现‘ or moneytype=‘线下提现‘) and state=1 and paytime between ‘2016-07-11 00:00:00‘ and ‘2016-07-11 23:59:59‘

union all select sum(amount) from [YYD_Account_MoneyRecord]
where (moneytype=‘提现‘ or moneytype=‘线下提现‘) and state=1 and paytime between ‘1980-01-01‘ and ‘2016-07-11 23:59:59‘
union all select sum(USableAmount) from [YYD_Account_AccountInfo]

--首充数量(当天)
union all select COUNT(*) from YYD_Users_RegInfo
where ID in(select distinct user_id from YYD_Account_RechargeRecord where amount>0 and state=1)
and regTime between ‘2016-07-11 00:00:00‘ and ‘2016-07-11 23:59:59‘
--累计充值人数
union all select COUNT(*) from YYD_Users_RegInfo
where regTime between ‘1980-01-01‘ and ‘2016-07-11 23:59:59‘ and
ID in(select distinct user_id from YYD_Account_RechargeRecord where amount>0 and state=1)
--充值人数(当天)
union all select COUNT(*) from YYD_Account_RechargeRecord where amount>0 and state=1
and createtime between ‘2016-07-11 00:00:00‘ and ‘2016-07-11 23:59:59‘

时间: 2024-12-15 00:09:10

投资统计查询sql的相关文章

统计查询-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 Mobi

电Call记录统计查询sql

DECLARE @startTime datetimeset @startTime='2016-07-12' 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

mysql按年度、季度、月度、周、日统计查询的sql语句

本文介绍一些mysql中用于查询的sql语句,包括按年度.季度.月度.周.日统计查询等,有需要的朋友,可以参考下. 一.年度查询 查询 本年度的数据 SELECT * FROM blog_article WHERE year( FROM_UNIXTIME( BlogCreateTime ) ) = year( curdate( )) 二.查询季度数据 查询数据附带季度数 SELECT ArticleId, quarter( FROM_UNIXTIME( `BlogCreateTime` ) )

010.简单查询、分组统计查询、多表连接查询(sql实例)

-------------------------------------day3------------ --添加多行数据:------INSERT [INTO] 表名 [(列的列表)] --SELECT UNION --SELECT 'HAHA',1,32--UNION ALL --全部显示/显示重复数据 即使集合相同--UNION---------将查询的两个结果集合并.结构必须一致 -->常见面试题 --SELECT 'HEHE',2,33------将查询结果添加到列表中(子查询)IN

[原创]java WEB学习笔记92:Hibernate学习之路-- -QBC 检索和本地 SQL 检索:基本的QBC 查询,带 AND 和 OR 的QBC,统计查询,排序,分页

本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱好者,互联网技术发烧友 微博:伊直都在0221 QQ:951226918 -----------------------------------------------------------------------------------------------------------------

--投资情况统计详情sql

--投资情况统计详情sqlselect BidRecord.*, RegInfo.UserName,UserInfo.phone,BorrowInfo.Title,BorrowInfo.BorrowCode from--(select * from [YYD_Account_MoneyRecord] where moneytype='参与投标' and state=1) as MoneyRecord(select * from YYD_Borrow_BidRecord where status=

Mysql 按年度、季度、月度、周、日SQL统计查询

mysql没有提供unix时间戳的专门处理函数,所以,如果遇到时间分组,而你用的又是整型unix时间戳,则只有转化为mysql的其他日期类型! FROM_UNIXTIM()将unix时间戳转为datetime等日期型! 特殊情况:createtime为int时,写法如下 select * from paycord where month(FROM_UNIXTIME(createtime, '%y-%m-%d')) = month(curdate()) and year(FROM_UNIXTIME

sql 分组统计查询并横纵坐标转换

关于sql 分组统计查询,我们在做报表的时候经常需要用到;今天就在这里整理下; 先附上一段sql代码: if object_id(N'#mytb',N'U') is not null drop table #mytbgodeclare @Year intset @Year=2014create table #mytb ([Date] int,[Count] int,[Price] decimal(18, 0),[spbm] varchar(50),[sppp] varchar(100),[spm

thinkphp区间查询、统计查询、SQL直接查询

区间查询 $data['id']=array(array('gt',4),array('lt',10));//默认关系是(and)并且的关系 //SELECT * FROM `tp_user` WHERE ( (`id` > 4) AND (`id` < 10) ) $data['id']=array(array('gt',4),array('lt',10),'or') //关系就是(or)或者的关系 $data['name']=array(array('like','%2%'),array(