mysql - Get count of ids from a table grouped by a some range of values -


i have table this

------------------- id    | rating ------------------- 1     | 1.2 ------------------- 2     | 1.3 ------------------- 3     | 2.3 

i want result

rating   row ------------ 1        0 2        2 3        1 4        0 5        0 

as row rating less 1 0 row rating greater 1 , less 2 2 row rating greater 2 , less 3 1 row rating greater 3 , less 4 0 row rating greater 4 , less 5 0

i totally blank how make query me please

select table.*, ceil(rating) integer_rating table order rating asc

ceil() rounds number larger x.0 integer (x+1). problem 0.2 return 1 , not 0 like. can quick comparison outside of sql change zero.

this return:

id    rating  integer_rating ---------------------------- 1    1.2      2 2    1.3      2 3    2.3      3 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -