我有一张带有ip地址列的桌子。我想找出排名前五的地址。
现在我正在计划如下:
count(id) where IP='{ip}'和存储计数(count缺点包括如果我有500个ip地址。这是我必须运行的500个查询,以确定什么是前五名。
我想构建一个这样的查询
select ip from table where 1 order by count({distinct ip}) asc limit 5发布于 2010-04-29 02:16:27
select ip, count(*)
from table
group by ip
order by count(*) desc limit 5发布于 2010-04-29 02:15:54
select IP, count(IP) as IPCount from TABLE
group by IP
order by IPCount DESC
Limit 5有:)
https://stackoverflow.com/questions/2734366
复制相似问题