我的表向有这些字段:
id int(6) not null,
position bigint(12) not null,
name....position记录一些位置信息,这个位置范围大约是从0到100,000,000,甚至更大,现在要统计记录的分布,比如要查找30,000到500,000之间,以500为单位,统计每个单位的记录数这样的查询要怎么写呢?如果查询语句做不了,有什么好的方法吗?
id int(6) not null,
position bigint(12) not null,
name....position记录一些位置信息,这个位置范围大约是从0到100,000,000,甚至更大,现在要统计记录的分布,比如要查找30,000到500,000之间,以500为单位,统计每个单位的记录数这样的查询要怎么写呢?如果查询语句做不了,有什么好的方法吗?
mysql> select count(*) from test where position between 1000 and 1000
000 group by floor(position/500);
看来分要给我自己了