---隨心買統計查詢
--隨心買新增-當日人次
select count(*) from(select distinct userid from hur_product_buy where createdate between '2016-07-12 00:00:00' and '2016-07-12 23:59:59') as a
--隨心買新增-累計總人次
union all select count(*) from(select distinct userid from hur_product_buy where createdate between '1980-01-01' and '2016-07-12 23:59:59') as b
--隨心買新增-當日金額
union all select sum(amount) from hur_product_buy where createdate between '2016-07-11 00:00:00' and '2016-07-11 23:59:59'
--隨心買新增-累計總金額
union all select sum(amount) from hur_product_buy where createdate between '1980-01-01' and '2016-07-11 23:59:59'
--隨心買退出-當日人次
union all select count(*) from(select distinct userid from hur_product_buy where (status=2 or status=3) and updatedate between '2016-07-11 00:00:00' and '2016-07-11 23:59:59') as c
--隨心買退出-累計總人次
union all select count(*) from(select distinct userid from hur_product_buy where (status=2 or status=3) and updatedate between '1980-01-01' and '2016-07-11 23:59:59') as d
--隨心買退出-當日金額
union all select sum(amount) from hur_product_buy where (status=2 or status=3) and updatedate between '2016-07-12 00:00:00' and '2016-07-12 23:59:59'
--隨心買退出-累計總金額
union all select sum(amount) from hur_product_buy where (status=2 or status=3) and updatedate between '1980-01-01' and '2016-07-12 23:59:59'
select * from(
select ext.exitid,ext.exitamount,ext.createdate,ext.exitstatus,
(select username from yyd_users_reginfo where id = ext.userid) username,
(select amount from hur_product_buy where buyid = ext.buyid) amount,
(select rankname from hur_product_buy where buyid = ext.buyid) rankname
from hur_product_exit as ext) as data where 1=1
select * from hur_product_buy order by createdate desc
select sum(amount) as totalextamount from(select buy.buyid,buy.amount,buy.status,buy.platform,buy.updatedate,
(select username from yyd_users_reginfo where id = buy.userid) username from hur_product_buy as buy where (status=2 or status=3)) as data
where username like '%dd%'
select buy.buyid,buy.amount,buy.status,buy.platform,buy.updatedate,
(select username from yyd_users_reginfo where id = buy.userid) username from hur_product_buy as buy where (status=2 or status=3)
sql統計查詢
手機簡訊記錄表 create table smslogs id int primary key identity 1,1 自增id mobile nvarchar 20 not null,手機號碼 smscontent nvarchar 255 簡訊內容 mobilecity nvarchar 20...
MYSQL 統計查詢
mysql 統計查詢 mysql查詢統計報表 獲取當前時間截 html view plaincopyprint?select unix timestamp now 獲取當天零時時間截 html view plaincopyprint?select unix timestamp curdate 統計當...
Mysql 列轉行統計查詢 行轉列統計查詢
之前看過一篇博文寫得非常好,看後就很容易讓人理解,博文位址為 最近在群裡又碰到乙個朋友說起,於是記錄一下 假設表名為t.表裡有六個欄位p1,p2,p3,s1,s2,s3 現在想得到 p1 100 時s1值的總和 p2 100 時s2值的總和 p3 100 時s3值的總和 建立表 create tab...