SELECT * FROM s a WHERE EXISTS (SELECT COUNT(*) FROM s b WHERE b.city=a.city AND a.id>b.id HAVING COUNT(*)<6) ORDER BY a.city,a.startip DESC
好比以上 按城市分組,每組取出5條ip地址段落sql