投資統計查詢sql

2021-09-08 18:53:23 字數 2719 閱讀 5183

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'

sql統計查詢

手機簡訊記錄表 create table smslogs id int primary key identity 1,1 自增id mobile nvarchar 20 not null,手機號碼 smscontent nvarchar 255 簡訊內容 mobilecity nvarchar 20...

SQL 多表連線統計查詢

select y ygzltbl.fz,y ygzltbl.gh,y ygzltbl.xm,y ygzltbl.ye,sum y sktbl.kkje sum y cztbl.je from y ygzltbl left join y sktbl on y ygzltbl.gh y sktbl.gh...

SQL查詢各階段的統計資訊

我們常常會遇到各種分類統計問題,需要將這些結果一次顯示出來。這次老師提出的要求是我想看60分以下多少人,60 70多少人,70 80多少人,80 90多少人,90 100多少人。他們以前做的統計資訊是,相同分數的有多少人,不同的分數都會在chart圖表裡顯示一列,這樣的效果通常是不被需要的,而且資料...