I have a table with messages per user:
users
----------------
user_id messages
----------------
725 0
30 0
1436 1
10454 4
. .
. .
1507 901
The table contains 74,500 users. The table is sorted ASC for the numer of messages. I now want to count the number of tweets per percentile, so:
SELECT SUM(messages) FROM users LIMIT 0, 745;
SELECT SUM(messages) FROM users LIMIT 745, 745;
SELECT SUM(messages) FROM users LIMIT 1490, 745;
.
.
SELECT SUM(messages) FROM users LIMIT 73755, 745;
I can do this, no problem. And I could write a script to fire the queries to the database. But I was wondering, isn’t it possible to let MySQL output the total number of messages per usergroup? So the output would be something like
group users total_messages
-----------------------------------
1 0 - 745 451
2 745 - 1490 5627
. . . .
. . . .
100 73755 - 74500 2654
try this:
if you want group range also to be displayed , you could do this