I have a table of seat numbers and marks like this:
seat marks
61 45
62 25
63 45
64 23
65 25
66 9
67 23
The max mark is 100. Now I want to display how many candidates are securing marks in 10s, 20s, 30, .... 100s
marks candidates_count
10 1
20 4
30 0
.. ..
And so on. Now I know this
SELECT seat, marks, count(marks) as counts from <table> group by marks order by counts desc;
or do this for each 10s, 20s and 30s
SELECT seat, marks from <table> where marks>10 and marks<=20 group by marks;
and get the num of rows returned in my php and return the results, but thats not very elegant. There must be a way to do that directly in MySQL and without using MySQL for loops.