请问如何实现统计一周内的数据,一月内的数据等等!
例如有一张表(A),A表假设就有两个字段:ID,Data。
怎么判断data是在一周内,一月内。一年内的数据总和
例如有一张表(A),A表假设就有两个字段:ID,Data。
怎么判断data是在一周内,一月内。一年内的数据总和
解决方案 »
- 谁能教我一个辨认Oracle数据库的位置方法
- 求一Oracle 存储过程的写法
- sqlplus如何连接远程oracle?
- sqf%rowcount 到底可以使用几次,如下边的格式,oracle 知道是哪个sql%rowcount 吗 请高手指点
- 在程序发布的时候 有什么文件可以替代客户端的安装(在线等代)
- 无法访问系统表tab如何解决??
- 百万数据写库,效率问题?
- 为什么筛选出来的时间变成12H的呢?如何变成24H
- 触发器编译时提示“触发器中不能包含LONG型字段“,但确实没有定义和指向这种类型的字段
- SQL语句求教
- Oracle中的游标使用问题
- SLEEP(30); 和DBMS_LOCK.SLEEP(30); 有什么区别?
时间哪里体现
月:select * from A where to_char(date,'yyyymm')='200911'
年:select * from A where to_char(date,'yyyy')='2009'
统计总量,count就可以了,不用管具体的东西
select * from table1 where datetime>sysdate-7
一年内的
select * from table1 where datetime>add_months(sysdate,-12)
一月内
where datetime>add_months(sysdate,-1)本周内
where to_char(datetime,'yyyyiw')=to_char(sysdate,'yyyyiw')
本年内
where datetime>=trunc(sysdate,'yyyy')
本月内
where datetime>=trunc(sysdate,'mm')
select to_char(sysdate,'ww') from dual;查询45周的记录
周:select * from A where to_char(date,'ww')='45'
select to_char(times ,'yyyy-MM') ,count(*) from times group by to_char(times,'yyyy-MM');
按年
select to_char(times ,'yyyy') ,count(*) from times group by to_char(times,'yyyy');
按周 最笨的办法就是用between ...