如果Oracle数据库的USER_ACCESS表里有USER_NAME, LOGIN_TIME字段存储用户的登陆时间,可以使用to_char函数就行分时段统计
1. 按小时统计访问人数,并且按访问次数降序显示:
select to_char(LOGIN_TIME, 'hh24'), count(*) from USER_ACCESS where LOGIN_TIME > to_date('2013/01/01','YYYY/MM/dd') group by to_char(LOGIN_TIME, 'hh24') order by count(*) desc;
2.按天数统计:
select to_char(LOGIN_TIME, 'YYYY-MM-dd'), count(*) from USER_ACCESS
3. 按月份统计:
select to_char(LOGIN_TIME, 'YYYY-MM'), count(*) from USER_ACCESS