Woops!  Forget I said that, you wanted to order by the most occurrences.
Sorry.

SELECT ip, count(*) FROM iptable GROUP BY ip ORDER BY 2 DESC limit 10;

Heh... I should learn to read one of these days...

-Matt


-----Original Message-----
From: rmck [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 01, 2004 1:03 PM
To: [EMAIL PROTECTED]
Subject: Select help

Hi,

I have a table with ip,port and I want to see the top ten Ip's with the
most entries? 
Ip's can be in db many times...

Not the first distinct 10... Im stuck...

I have tried:
mysql> select DISTINCT ip from iptable limit 10;

+---------------+
| ip           |
+---------------+
| 0.0.0.0       |
| 10.0.1.42     |
| 10.0.1.8      |
| 10.1.1.1      |
| 10.10.10.1    |
| 10.115.94.193 |
| 10.115.94.195 |
| 10.115.94.40  |
| 10.122.1.1    |
| 10.20.7.184   |
+---------------+
10 rows in set (0.04 sec)
 
mysql> 

But doesn't that just give the first 10 DISTINCT ip's?? 

rob




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to