select id,user_name,sum(stay_time) sumtimes,avg(stay_time) avgtime,sum(stay_time)/7 dailytime
from mytable where ......
group by id,user_namesumtimes是总登录时间,avgtime是所有登录时间的平均值,他没登录就不算,dailytime是没登录也算一天取平均。where的时间段你自己写
from mytable where ......
group by id,user_namesumtimes是总登录时间,avgtime是所有登录时间的平均值,他没登录就不算,dailytime是没登录也算一天取平均。where的时间段你自己写
sum(stay_time)/xxxx(min(login_time))weeklytime
from mytable where ......
group by user_name xxxx 方法为当前时间减初次登陆时间,然后算出总共登陆的周数!公司没有oracle,就写个大概思路!