mysql小试题
1. 用户登录日志表 xes_user_login_logs 如下:
(1) 检索登录超过两次的用户ID(sql语句)
select user_id from vvt_ceshi group by user_id having(count(user_id))>1;
HAVING 就像WHERE条件一样,按指定要求来取数据集。只不过WHERE一般数据查询来指定条件,HAVING是用在GROUP BY 分组来指定条件
(2) 检索登录超过两次的总数(SQL语句)
select count(sum) from (select count(user_id) as sum from vvt_ceshi group by user_id having(count(user_id))>1) as b;
2.