Home  >  Article  >  Database  >  SQL中Group分组获取Top N 方法实现

SQL中Group分组获取Top N 方法实现

WBOY
WBOYOriginal
2016-06-07 17:43:34955browse

有产品表,包含id,name,city,addtime四个字段,因报表需要按城市分组,统计每个城市的最新10个产品,便向该表中插入了100万数据,做了如下系列测试: . ( ( 1 , 1 ) NOT NULL , ( 50 ) NULL , , ( 10 ) NULL , ( ) , IGNORE_DUP_KEY , ALLOW_PAGE_LOCKS )

有产品表,包含id,name,city,addtime四个字段,香港服务器,因报表需要按城市分组,统计每个城市的最新10个产品,便向该表中插入了100万数据,做了如下系列测试:

.( (1,1) NOT NULL, (50) NULL, , (10) NULL, ( ), IGNORE_DUP_KEY , ALLOW_PAGE_LOCKS ) ,美国空间,香港服务器租用

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn