日期:2014-05-16 浏览次数:20937 次
select date,max(col2)
from
(select date,case substr(col2,-2,2)
when '01' then col2
when '02' then col2
....
when '23' then col2
else 0 end as col2
from t)
group by date;
with test as (
select '2012-10-1' as str1, '11' as str2 from dual
union all
select '2012-10-2' as str1, '12' as str2 from dual
union all
select '2012-10-3' as str1, '13' as str2 from dual
union all
select '2012-10-4' as str1, '14' as str2 from dual
union all
select '2012-10-5' as str1, '15' as str2 from dual
union all
select '2012-11-1' as str1, '12' as str2 from dual
union all
select '2012-11-2' as str1, '22' as str2 from dual
union all
select '2012-11-3' as str1, '32' as str2 from dual
union all
select '2012-11-4' as str1, '42' as str2 from dual
union all
select '2012-11-5' as str1, '52' as s