我目前需要按周统计数据,我自己能够按自然周统计,但是现在需要一周的统计时间与自然周偏移3天;
例如自然周是周一到周日,我现在统计的一周是上周五到本周四,请问如果写SQL语句??
select sum(a),sum(b),sum(c),sum(d),sum(e),sum(g),f from
(
select count(*) a,0 as b,0 as c,0 as d,0 as e,0 as g,to_char(complaints_date,'ww') f from dh_complaints t
where complaints_Type='类型' and complaints_date between :begin_Time and :end_Time
group by to_char(complaints_date,'ww')
) x
group by x.f
例如自然周是周一到周日,我现在统计的一周是上周五到本周四,请问如果写SQL语句??
select sum(a),sum(b),sum(c),sum(d),sum(e),sum(g),f from
(
select count(*) a,0 as b,0 as c,0 as d,0 as e,0 as g,to_char(complaints_date,'ww') f from dh_complaints t
where complaints_Type='类型' and complaints_date between :begin_Time and :end_Time
group by to_char(complaints_date,'ww')
) x
group by x.f
解决方案 »
- 行列转换~~~想不出了
- 如何将查询结果集中的某列值(字符串)合并?
- SQL*Net是否是加密进行传输的
- 再送100分:用DBMS_XMLQuery.getXML生成XML文件时,修改嵌套表的行标签,请看代码请指教!!
- oracleDB 无法启动
- 请教:ORA-01219:数据库未打开:仅允许在固定表/食堂中查询。
- 在程序中调用存储过程时出现引用超出范围是什么意思?怎么解决?
- 请教高手:实现一个从3300万记录中汇总排序查询,需把sort_area_size设置为多大合适?能否超过shared_pool_size?这有什么规定?(急!!
- 如何查看Oracle中sql语句的执行时间
- 关于Oracle数据库
- 请问:linux文件路径问题。
- 这个oracle存储过程怎么写
至于加几自己测试;
select sum(a), sum(b), sum(c), sum(d), sum(e), sum(g), f
from (select count(*) a,
0 as b,
0 as c,
0 as d,
0 as e,
0 as g,
to_char(complaints_date - 3, 'ww') f
from dh_complaints t
where complaints_Type = '类型'
and complaints_date - 3 between :begin_Time and :end_Time
group by to_char(complaints_date - 3, 'ww')) x
group by x.f;