create table ValTable as
select to_date('2007/01/01','YYYY/MM/DD') as sellDay,150 as Val from dual
union select to_date('2007/01/04','YYYY/MM/DD'),200 from dual
union select to_date('2007/01/09','YYYY/MM/DD'),250 from dual
union select to_date('2007/01/10','YYYY/MM/DD'),300 from dual
union select to_date('2007/01/11','YYYY/MM/DD'),350 from dual
union select to_date('2007/01/15','YYYY/MM/DD'),400 from dual
union select to_date('2007/01/19','YYYY/MM/DD'),450 from dual
union select to_date('2007/01/20','YYYY/MM/DD'),500 from dual
union select to_date('2007/01/21','YYYY/MM/DD'),550 from dual
union select to_date('2007/01/30','YYYY/MM/DD'),600 from dual
union select to_date('2007/01/31','YYYY/MM/DD'),650 from dual
union select to_date('2007/02/09','YYYY/MM/DD'),700 from dual
union select to_date('2007/02/10','YYYY/MM/DD'),750 from dual
union select to_date('2007/02/11','YYYY/MM/DD'),800 from dual
union select to_date('2007/02/19','YYYY/MM/DD'),850 from dual
union select to_date('2007/02/20','YYYY/MM/DD'),900 from dual
union select to_date('2007/02/21','YYYY/MM/DD'),950 from dual
union select to_date('2007/02/27','YYYY/MM/DD'),960 from dual
union select to_date('2007/02/28','YYYY/MM/DD'),970 from dual;
select sellDay,sum(Val) as Val
from (select
to_char(sellDay,'yyyy"年"fmmm"月"') ||
case when extract(day from sellDay) <= 10 then '初旬'
when extract(day from sellDay) <= 20 then '中旬'
else '下旬' end as sellDay,
Val
from ValTable)
group by sellDay
order by substr(sellDay,1,instr(sellDay,'月')),
decode(substr(sellDay,-2),'初旬',1,'中旬',2,'下旬',3);