(转)SQL按照日、周、月、年统计数据
写sql语句分别按日,星期,月,季度,年统计销售额
--按日
select sum(consume),day([date]) from consume_record where year([date]) = '2006' group by day([date])
--按周quarter
select sum(consume),datename(week,[date]) from consume_record where year([date]) = '2006' group by datename(week,[date])
--按月
select sum(consume),month([date]) from consume_record where year([date]) = '2006' group by month([date])
--按季
select sum(consume),datename(quarter,[date]) from consume_record where year([date]) = '2006' group by datename(quarter,[date])
--按年
select sum(consume),year([date]) from consume_record where group by year([date])
(转)SQL按照日、周、月、年统计数据的更多相关文章
- Flex自定义组件开发之日周月日期选择日历控件
原文:Flex自定义组件开发之日周月日期选择日历控件 使用过DateField的我们都知道,DateField 控件是用于显示日期的文本字段,字段右侧带有日历图标.当用户在控件边框内的 ...
- pg按日,周,月进行数据统计
pg数据库按周,月统计数据 SELECT date_trunc('WEEK', insert_time) as insertDate, SUM(data_increment) as dataTotal ...
- mysql按日/周/月统计
一.mysql按日统计 ) count ' and start_time > '2017-06-28' group by days; 二.mysql按周统计 ) ' group by weeks ...
- MySql 按日,按周,按月 分组 统计数据
知识关键词:DATE_FORMAT 按天统计: SELECT DATE_FORMAT(create_time,'%Y%m%d') days, COUNT(caseid) count FROM tc_c ...
- MySql查询日周月
常用计算日期的函数 日 date(日期) = CURDATE() 自然周 YEARWEEK(date_format(日期,'%Y-%m-%d') , 1) = YEARWEEK(now() , 1) ...
- sql按月统计数量和按月累加统计数量
1.简单的,按月统计数量 SELECT CREATE_DATE, DATE_FORMAT(CREATE_DATE, '%Y-%m') AS month , COUNT(*) AS sum FROM p ...
- SQL周、日、月、年数据统计
本文只是记录在项目中用到的统计的SQL语句,记一笔以防忘了 /// <summary> /// 获取统计数据 /// </summary> /// <param name ...
- 转载:SQL按照日、周、月、年统计数据的方法
转载源:http://www.jb51.net/article/42613.htm SQL按照日.周.月.季度.年统计数据的方法 方式一: --按日 select sum(consume),day([ ...
- 实现日、周、月排行统计 sql
在如今很多系统中,都需要进行日.周.月排行统计,但是在网上寻找 了一番,发现很多都是相对的周.月排行,即周排行则用当前时间减去7天.这样我个人认为并不恰当.如月排行中,假设今天是4月22日,则从3月2 ...
- 用sql语句按周、按月、按季、按年统计
--按mySql语法统计按周,月,季,年.income为合计的价格字段,createDate为交易时间. select sum(income)as revenue,week(createDate) a ...
随机推荐
- NEUOJ 1117: Ready to declare(单调队列)
1117: Ready to declare 时间限制: 1 Sec 内存限制: 128 MB 提交: 358 解决: 41 [提交][状态][pid=1117" style=" ...
- codeforces 468B 2-sat
今天明确了2-SAT; 表示对一对整数之间的关系是否存在 #include<cstdio> #include<algorithm> #include<iostream&g ...
- ROR 环境的 搭建
1)安装RUBY:从 http://www.ruby-lang.org/en/ 下载 ruby182-15.exe,安装Ruby.ruby -v 看是否安装成功.2)安装RAILS框架 :gem in ...
- C# 循环获取目录
#region 获取目录 /// <summary> /// 获取指定文件夹下所有子目录及文件 /// </summary> /// <param name=" ...
- [Ramada] Build a Functional Pipeline with Ramda.js
We'll learn how to take advantage of Ramda's automatic function currying and data-last argument orde ...
- [AngularJS] Consistency between ui-router states and Angular directives
ui-router's states and AngularJS directives have much in common. Let's explores the similarities bet ...
- 忘记redhat linux root密码怎么办
自己VM虚拟机里安装redhat linux root密码忘了,刚开始想重新安装,但是后来想到还有linux有一个single模式,使用single可以直接进入字符界面,然后修改: 启动vm虚拟机,启 ...
- nandsim ubi nand nor
nandsim模拟mtd测试UBI模块 利用nandsim挂载ubi文件系统 MTD设备及JFFS2, UBIFS文件系统的使用简介 首先需要安装mtd_utils工具: sudo apt-get i ...
- Storm中并发程度的理解
Storm中涉及到了很多组件,例如nimbus,supervisor等等,在参考了这两篇文章之后,对这个有了更好的理解. Understanding the parallelism of a Stor ...
- 记录asp.net网站停止运行原因的代码
记录网站是什么原因导致停止运行还是有必要的,下面是具体的实现方式. protected void Application_End(object sender, EventArgs e) { Recor ...