日期:2014-05-17 浏览次数:20825 次
with t as
(select 2013 y,1 m,0.51 s from dual
union all
select 2013 y,6 m,0.54 s from dual
union all
select 2013 y,7 m,0.53 s from dual
union all
select 2013 y,8 m,0.54 s from dual
union all
select 2013 y,9 m,0.5 s from dual
)
select to_date(y
------解决方案--------------------
'-'
------解决方案--------------------
m,'YYYY-MM'),sum(s) from t
where to_date(y
------解决方案--------------------
'-'
------解决方案--------------------
m,'YYYY-MM') between to_date('2013-06','YYYY-MM') and to_date('2013-08','YYYY-MM')
group by to_date(y
------解决方案--------------------
'-'
------解决方案--------------------
m,'YYYY-MM')
order by to_date(y
------解决方案--------------------
'-'
------解决方案--------------------
m,'YYYY-MM')
select ASSESS_YEAR,ASSESS_MONTH,score
from t
where ASSESS_YEAR=2012 and (ASSESS_MONTH between 8 and 12)
union all
select ASSESS_YEAR,ASSESS_MONTH,score
from t
where ASSESS_YEAR=2013 and (ASSESS_MONTH between 1 and 6)
--没有排序,影响性能
--如果要排序,加一个嵌套做ORDER ASSESS_YEAR,ASSESS_MONTH