---to buy statistics query

Source: Internet
Author: User

---to buy statistics query

--Buy new-day trips
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
--Buy new-total number of visitors
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

--Buy new-day amount
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 '
--Buy new-Cumulative total amount
UNION ALL Select SUM (amount) from hur_product_buy where createdate between ' 1980-01-01 ' and ' 2016-07-11 23:59:59 '


--Buy your own exit-day trips
UNION ALL Select COUNT (*) from (SELECT distinct UserID from Hur_product_buy where (status=2 or status=3) and updatedate bet Ween ' 2016-07-11 00:00:00 ' and ' 2016-07-11 23:59:59 ') as C
--Buy your own exit-cumulative total number of passengers
UNION ALL Select COUNT (*) from (SELECT distinct UserID from Hur_product_buy where (status=2 or status=3) and updatedate bet Ween ' 1980-01-01 ' and ' 2016-07-11 23:59:59 ') as D

--Buy your own exit-the amount of the day
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 '
--Buy your own exit-cumulative total Amount
UNION ALL Select SUM (amount) from Hur_product_buy where (status=2 or status=3) and updatedate between ' 1980-01-01 ' and ' 20 16-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 STA tus=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 STA tus=3)



---to buy statistics query

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.