SELECT ip, COUNT(ip) as count FROM gnb_full_log GROUP BY ip
这将返回带有 ip 和 count 列的表。我想选择 count = 1 OR 1 < count < 6 的记录
SELECT ip, COUNT(ip) as count FROM gnb_full_log GROUP BY ip
这将返回带有 ip 和 count 列的表。我想选择 count = 1 OR 1 < count < 6 的记录
使用HAVING
子句:
SELECT ip, COUNT(*) as count
FROM gnb_full_log
GROUP BY ip
HAVING count = 1
或者
SELECT ip, COUNT(*) as count
FROM gnb_full_log
GROUP BY ip
HAVING 1 < count AND count < 6
尝试这个:
SELECT ip, COUNT(ip) as count
FROM gnb_full_log GROUP BY ip
HAVING COUNT(ip) >= 1 and COUNT(ip) < 6
HAVING 子句在聚合函数上是 WHERE
用这个:-
SELECT ip, COUNT(ip) as count FROM gnb_full_log GROUP BY ip HAVING count > 1 AND count < 6