1. 用戶登錄日誌表 xes_user_login_logs 如下: (1) 檢索登錄超過兩次的用戶ID(sql語句) (2) 檢索登錄超過兩次的總數(SQL語句) 2. ...
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.