select sum(case when to_char(etr_date, 'hh24') = '00' then count(*) else 0 end) as "00", sum(case when to_char(etr_date, 'hh24') = '01' then count(*) else 0 end) as "01", ... ... sum(case when to_char(etr_date, 'hh24') = '22' then count(*) else 0 end) as "22", sum(case when to_char(etr_date, 'hh24') = '23' then count(*) else 0 end) as "23" from table group by etr_date
select to_char(etr_date,'hh') from Table where to_char(etr_date,'dd')='2011-09-05' group by to_char(etr_date,'hh')
select sum(case when to_char(etr_date, 'hh24') = '00' then count(*) else 0 end) as "00",
sum(case when to_char(etr_date, 'hh24') = '01' then count(*) else 0 end) as "01",
... ...
sum(case when to_char(etr_date, 'hh24') = '22' then count(*) else 0 end) as "22",
sum(case when to_char(etr_date, 'hh24') = '23' then count(*) else 0 end) as "23"
from table
group by etr_date
学习ing ~~~~