select * from (select count(1) as login_times,user_id from user_login_table where login_datetime between '2015-10-26 00:00:00' and '2015-11-26 00:00:00' group by date_format(login_datetime,'%m-%d-%Y' ') as b where b.login_times > 3
select a.userid from(select userid,date_format() from t_login where logindate between and group by userid,date_format() ) a group by userid having count(1)>3;
' ) as b where b.login_times > 3