日期:2014-05-17 浏览次数:21335 次
with t as
(select 1 as id,'2012-01-01' as times from dual
union all
select 2 as id,'2012-02-01' as times from dual
union all
select 3 as id,'2012-03-01' as times from dual
union all
select 4 as id,'2012-04-01' as times from dual
union all
select 5 as id,'2012-06-01' as times from dual
union all
select 6 as id,'2012-07-01' as times from dual
union all
select 7 as id,'2012-08-01' as times from dual
union all
select 8 as id,'2012-09-01' as times from dual
union all
select 9 as id,'2012-10-01' as times from dual
union all
select 11 as id,'2011-01-01' as times from dual
union all
select 12 as id,'2011-02-01' as times from dual
union all
select 13 as id,'2011-03-01' as times from dual
union all
select 14 as id,'2011-04-01' as times from dual
union all
select 15 as id,'2011-06-01' as times from dual
union all
select 16 as id,'2011-07-01' as times from dual
union all
select 17 as id,'2011-08-01' as times from dual
union all
select 18 as id,'2011-09-01' as times from dual
union all
select 19 as id,'2011-10-01' as times from dual)
Select Count(1),dates From (
select id,case when to_char(to_date(times,'yyyy-mm-dd'),'mm')>='06' then to_char(to_date(times,'yyyy-mm-dd'),'yyyy')
------解决方案--------------------
'上半年' else to_char(to_date(times,'yyyy-mm-dd'),'yyyy')
------解决方案--------------------
'下半年' end as dates from t)
group by dates
order by 2;
with t as
(select 1 as id,'2012-01-01' as times from dual
union all
select 2 as id,'2012-02-01' as times from dual
union all
select 3 as id,'2012-03-01' as times from dual
union all
select 4 as id,'2012-04-01' as times from dual
union all
select 5 as id,'2012-06-01' as times from dual
union all
select 6 as id,'2012-07-01' as times from dual
union all
select 7 as id,'2012-08-01' as times from dual
union all
select 8 as id,'2012-09-01' as times from dual
union all
select 9 as id,'2012-10-01' as times from dual
union all
select 11 as id,'2011-01-01' as&nbs