如果我有一个看起来像这样的表
id ip
------ ---------
1 192.212.1.1
2 192.212.1.1
3 156.232.1.1
4 192.212.1.1
5 192.212.1.1
6 561.235.2.1
7 156.261.2.2
到目前为止,我已尝试过此查询
SELECT ip FROM voluum_clicks HAVING COUNT(ip) > 3;
我需要它返回的是
id ip
------ ---------
1 192.212.1.1
2 192.212.1.1
4 192.212.1.1
5 192.212.1.1
答案 0 :(得分:2)
SELECT * FROM voluum_clicks where ip in
(SELECT ip FROM voluum_clicks group by ip HAVING COUNT(ip) > 3)
答案 1 :(得分:1)
试试这个:
select
id,
ip
from voluum_clicks
where ip in
(
SELECT
ip
FROM voluum_clicks
GROUP by ip
HAVING COUNT(1) > 3
);
答案 2 :(得分:0)
## Warning in grid.Call(L_stringMetric,
as.graphicsAnnot(x$label)): font metrics unknown for
Unicode character U+043c
答案 3 :(得分:0)
你可以使用如下计数:
Select Id, [Ip] from (
Select *, count([id]) over(partition by [Ip]) as RCnt from #ipdata
) a Where a.RCnt >= 3
输出如下:
+----+-------------+
| Id | Ip |
+----+-------------+
| 1 | 192.212.1.1 |
| 2 | 192.212.1.1 |
| 4 | 192.212.1.1 |
| 5 | 192.212.1.1 |
+----+-------------+