---随心买统计查询
---隨心買統計查詢
--隨心買新增-當日人次
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)
轉載于:https://www.cnblogs.com/zxtceq/p/5703723.html
總結
以上是生活随笔為你收集整理的---随心买统计查询的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ACM: 畅通工程-并查集-解题报告
- 下一篇: 继续坚持