Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- need help with a query to count distinct items


GaryK - 6:06 am on Nov 16, 2010 (gmt 0)


My query skills are sorely lacking so hopefully someone can help me with this.

My table is called IPAddresses and it contains:

DateAdded as datetime
IPAddress as varchar(15)

I want to know what each distinct IPAddress is, and I also want to know what the total count for each distinct IPAddress is. I can easily do either one, but can't figure out a way to do both so that I have both the count and the actual IPAddress being counted.

My purpose is to see which IP Addresses are hitting a site of mine the most, so sorting in descending order of the total count would be helpful.

This is a query I'll be executing manually once a day or so, so I'm not too concerned with how efficient it is.

Thanks.


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4230869.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com