[snip]
iduser  |       dtaccess
-------------------------------
10              |       '2000-10-02'
3               |       '2000-12-04'
4               |       '2000-10-09'
3               |       '2000-12-04'
5               |       '2001-02-10'
10              |       '2001-03-01'
10              |       '2001-01-10'
10              |       '2001-01-11'
3               |       '2000-12-10'
--------------------------------

I need to group the records by the number of time some user (iduser) appears
in the table, and i need to know how many users appears once, how many
appears twice and so on.

Example: for these data, the resultset must bring:

num_times       |       num_users
-----------------------------
1               |       2
3               |       1
4               |       1
-----------------------------

i.e: 2 users appears twice, one user - three times, one user - four times.
Does anyone knows how can i do that?
[/snip]

SELECT COUNT(*) AS num_times, iduser
FROM table
GROUP BY iduser
ORDER BY num_times

HTH!

Jay

mysql, sql



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to