mysql 分組,而且每組中取出固定條數

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

相關文章
相關標籤/搜索