1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| With MaTable as
(
select '00001' as nm, to_date('2010-04-12 05:03:01', 'yyyy-mm-dd hh24:mi:ss') as dt from dual union all
select '00002', to_date('2010-04-12 05:31:02', 'yyyy-mm-dd hh24:mi:ss') from dual union all
select '00003', to_date('2010-04-12 05:33:03', 'yyyy-mm-dd hh24:mi:ss') from dual union all
select '00004', to_date('2010-04-12 05:34:04', 'yyyy-mm-dd hh24:mi:ss') from dual union all
select '00005', to_date('2010-04-12 05:59:05', 'yyyy-mm-dd hh24:mi:ss') from dual union all
select '00006', to_date('2010-04-12 06:03:01', 'yyyy-mm-dd hh24:mi:ss') from dual
)
select to_char(dt,'hh24') || ':00' as heure, count(*) as nbre
from MaTable
where trunc(dt) = date '2010-04-12'
group by to_char(dt,'hh24')
order by heure asc;
HEURE NBRE
05:00 5
06:00 1 |
Partager