获取MySQL中十进制范围的频率分布 [英] Get frequency distribution of a decimal range in MySQL

查看:90
本文介绍了获取MySQL中十进制范围的频率分布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种优雅的方法(就语法而言,不一定有效)来获取小数范围的频率分布.

I'm looking for an elegant way (in terms of syntax, not necessarily efficient) to get the frequency distribution of a decimal range.

例如,我有一个带有评分"列的表,该列可以是负数也可以是正数.我想获得具有一定范围等级的行的频率. -... -[-140.00至-130.00):5 -[-130.00至-120.00):2 -[-120.00至-110.00):1 -... -[120.00至130.00):17 -等等.

For example, I have a table with ratings column which can be a negative or positive. I want to get the frequency of rows with a rating of certain range. - ... - [-140.00 to -130.00): 5 - [-130.00 to -120.00): 2 - [-120.00 to -110.00): 1 - ... - [120.00 to 130.00): 17 - and so on.

[i到j)表示我包含j排除对象.

[i to j) means i inclusive to j exclusive.

提前谢谢.

推荐答案

您可以使用'select floor(rating/10),count(*)from(table)group by 1''来获得相当接近的结果

You could get pretty close using 'select floor(rating / 10), count(*) from (table) group by 1'

这篇关于获取MySQL中十进制范围的频率分布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆