---随心买统计查询

--随心买新增-当日人次
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)

时间: 2024-08-11 03:23:24

---随心买统计查询的相关文章

2016/3/13 七种查询 (普通查询 条件查询 排序查询 模糊查询 统计查询 分组查询 分页查询 )

一句话概括的话,SQL作为结构化查询语言,是标准的关系型数据库通用的标准语言: T-SQL 是在SQL基础上扩展的SQL Server中使用的语言 1,普通查询 #查询Info表中的所有列 select * from Info #查询Info表中的Name和Code列 select Name,Code from Info 2,条件查询 关键字where #查询Info表的左右列 限定范围 列名为p001 select * from Info where 列名="p001" #查询条件之

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

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

【Oracle 常用查询】oracle表空间使用率统计查询

参考1 --查询表空间使用情况 SELECT Upper(F.TABLESPACE_NAME) "表空间名", D.TOT_GROOTTE_MB "表空间大小(M)", D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)", To_char(Round(( D.TOT_GROOTTE_MB - F.TOTAL_BYTES ) / D.TOT_GROOTTE_MB * 100, 2), '990.99') || '

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

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

003.分组统计查询和表连接查询

--分组统计查询 group by having 1 select 分组字段 ,聚合函数 2 having 后常跟聚合函数,也可以跟分组字段 3 where 后不可以直接跟聚合函数 4 where(筛选行) -group by (分组) -having (筛选组) --表连接查询 1 笛卡尔积 (交叉连接 cross join) a*b A) SELECT * FROM A,B B) SELECT * FROM A CROSS JOIN B 2 内连接 原理: 将两个表中关联字段相等的行查询出来

【HQL】分页查询 、对象导航查询、外置命名查询、连接查询、查询过滤器、统计查询

分页查询 List students = session.createQuery("from Student") .setFirstResult(1) .setMaxResults(2) .list(); for (Iterator iter=students.iterator(); iter.hasNext();) { Student student = (Student)iter.next(); System.out.println(student.getName()); } 对象

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

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

分组统计查询(章节摘要)

1,在SQL中主要提供了5种分组函数,分别是COUNT(),AVG(),SUM(),MIN(),MAX()函数. 2,使用GROUP BY字句可以对数据进行分组操作,而使用HAVING字句可以对分组之后的数据进行再次过滤. 3,在分组时可以同时制定多个分组字段. 4,分组操作不仅可以用于实体表,也可以针对查询的临时表进行分组. 5,分组函数允许嵌套,但是嵌套之后的分组查询中不能再出现任何字段,包括分组字段.分组统计查询(章节摘要)

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