通过子查询来算吧:
比如统计1000-1530的a(10:00到15:30):select count(distinct(hao)) from A where A.code like 'a%' and a.date between to_date('20140331 10:00:00','yyyymmdd hh24:mi:ss') and to_date('20140331 15:30:00','yyyymmdd hh24:mi:ss')